Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet167/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   163   164   165   166   167   168   169   170   ...   453
lISTINg 8-4: 
 Handling timer events in a form
# 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’)
# Import the .NET assemblies.
FIguRE 8-7: 
The started application shows 
the current long time format.
continues
548592c08.indd 151
2/24/10 12:48:11 PM
www.finebook.ir


152

CHAPTER 8
Creating WindoWs Forms appliCations
import System
import System.Windows.Forms
# import the form.
from frmUseTimer import * 
# Define the event handlers.
def btnStart_Click(*args):
# Check the button status.
if TestForm.btnStart.Text == ‘&Start’:
# Start the timer.
TestForm.objTimer.Start()
# Change the button text.
TestForm.btnStart.Text = ‘&Stop’
else:
# Start the timer.
TestForm.objTimer.Stop()
# Change the button text.
TestForm.btnStart.Text = ‘&Start’
def btnQuit_Click(*args):
# Close the application.
TestForm.Close() 
def objTimer_Tick(*args):
# Handle the timer tick.
TestForm.lblTime.Text = System.DateTime.Now.ToLongTimeString() 
# Define the Windows Form and the elements of this specific instance.
TestForm = frmMain()
TestForm.InitializeComponent() 
# Always add event handlers after defining the Windows Form.
TestForm.btnStart.Click += btnStart_Click
TestForm.btnQuit.Click += btnQuit_Click
TestForm.objTimer.Tick += objTimer_Tick
# Run the application.
System.Windows.Forms.Application.Run(TestForm)
This example begins as any Windows Forms application does, by providing access to the .NET 
Framework directory and then importing the required assemblies after adding any required 
lISTINg 8-4 
(continued)
548592c08.indd 152
2/24/10 12:48:11 PM
www.finebook.ir



Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   163   164   165   166   167   168   169   170   ...   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