Professional IronPython


Interacting with Predefined and Custom Events



Download 20,35 Mb.
Pdf ko'rish
bet168/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   164   165   166   167   168   169   170   171   ...   453
Interacting with Predefined and Custom Events
 

 
153
references. The 
btnStart_Click()
event handler doesn’t just display a simple message this time. 
When the user clicks Start, the code checks the current 
TestForm.btnStart.Text
value. When this 
value is 
&Start
, the code calls 
TestForm.objTimer.Start()
, which starts the timer and changes 
the 
TestForm.btnStart.Text
value to 
&Stop
. When the value is 
&Stop
, the opposite sequence of 
events occurs. Figure 8-8 shows the dialog box with the timer started.
Starting 
objTimer
causes the component to begin emit-
ting 
Tick
events. The 
objTimer_Tick()
handles these 
Tick
events by updating the 
TestForm.lblTime.Text
with the latest time. Notice that even though you don’t 
add 
objTimer
to the window, you must still add the 
event handler to the event using 
TestForm.objTimer 
.Tick += objTimer_Tick
. In fact, you’ll often find that 
components require you to handle a number of events 
because events are the main form of communication for 
components (versus controls, which rely on their inter-
face elements for interaction and use events only to regis-
ter control changes so you can act on them).
Developing Your own Events
It’s true that the .NET Framework comes with more events than you’ll probably use in an entire life-
time. However, it’s also true that IronPython developers simply can’t see every need (and even if they 
did, it just wouldn’t pay to create a general event that only two people would ever use). Consequently, 
you’ll eventually need to create your own events to handle those situations that don’t neatly fit within 
someone else’s pigeonhole. The following sections show how to create a simple custom event that you 
can use as a model for creating events of your own.

Download 20,35 Mb.

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