Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet158/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   154   155   156   157   158   159   160   161   ...   453
Defining Windows Forms
 

 
143
lISTINg 8-1: 
 Designing the form and controls
# Set up the path to the .NET Framework. 
import sys
sys.path.append(‘C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727’)
# Make clr accessible.
import clr
# Add any required references.
clr.AddReference(‘System.Windows.Forms.DLL’)
clr.AddReference(‘System.Drawing.DLL’)
# Import the .NET assemblies.
import System 
import System.Windows.Forms
import System.Drawing.Point
class frmMain(System.Windows.Forms.Form):
# This function performs all of the required initialization.
def InitializeComponent(self):
# Configure btnOK
self.btnOK = System.Windows.Forms.Button()
self.btnOK.Text = “&OK”
self.btnOK.Location = System.Drawing.Point(263, 13)
# Configure btnCancel
self.btnCancel = System.Windows.Forms.Button()
self.btnCancel.Text = “&Cancel”
self.btnCancel.Location = System.Drawing.Point(263, 43)
# Configure lblMessage
self.lblMessage = System.Windows.Forms.Label()
self.lblMessage.Text = ‘This is a sample label.’
self.lblMessage.Location = System.Drawing.Point(13, 13)
self.lblMessage.Size = System.Drawing.Size(120, 13)
# Configure the form.
self.Text = ‘Simple Python Windows Forms Example’
self.ClientSize = System.Drawing.Size(350, 200)
# Add the controls to the form.
self.Controls.Add(self.btnOK)
self.Controls.Add(self.btnCancel)
self.Controls.Add(self.lblMessage)
The code begins by adding the .NET Framework path to 
sys.path
. It then uses 
clr.AddReference()
to add references for both 
System.Windows.Forms.DLL
and 
System.Drawing.DLL
. Finally, the code 
imports a number of .NET assemblies. The example uses individual 
import
statements for each assem-
bly. Theoretically, you can combine all the imports into a single 
import
statement, but most developers 
find using individual 
import
statements is a lot more readable and easy to maintain.
548592c08.indd 143
2/24/10 12:48:08 PM
www.finebook.ir



Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   154   155   156   157   158   159   160   161   ...   453




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish