dabodemo Commit
Revision 342
Date: 2005-11-27 15:58:35 -0800 (Sun, 27 Nov 2005)
Author: paul

Changed:
U   trunk/tutorial/autoBindEvents.py

Log:
Modified the tutorial code to show auto event binding to a panel's method
as well as the control and form.


Diff:
Modified: trunk/tutorial/autoBindEvents.py
===================================================================
--- trunk/tutorial/autoBindEvents.py    2005-11-22 22:38:45 UTC (rev 341)
+++ trunk/tutorial/autoBindEvents.py    2005-11-27 23:58:35 UTC (rev 342)
@@ -1,29 +1,32 @@
-# We are considering an autoBindEvents feature, which will interpret method 
-# names and automatically bind the appropriate events.
-
 import dabo
 import dabo.dEvents as dEvents
 
 app = dabo.dApp(MainFormClass=None)
 app.setup()
 
-# Turn on the experimental feature:
-dabo.autoBindEvents = True
-
 class MyButton(dabo.ui.dButton):
-       def initEvents(self):
-               # I'm binding this explicitly to show that there is now no 
"double-event" problem.
-               self.bindEvent(dEvents.Hit, self.onHit)
-
        def onHit(self, evt):
                print "MyButton.Hit"
 
+
+class MyPanel(dabo.ui.dPanel):
+       def initProperties(self):
+               self.Size = (100, 50)
+
+       def onMouseEnter(self, evt):
+               print "MyPanel.MouseEnter"
+
+       def onHit_btn1(self, evt):
+               print "panel: btn1 hit!"
+
+
 class MyForm(dabo.ui.dForm):
        def initProperties(self):
                self.Caption = "autoBindEvents() Demo"
 
        def afterInit(self):
-               self.addObject(MyButton, Caption="Hit me!", RegID="MyButton")
+               self.addObject(MyPanel, RegID="pan1")
+               self.pan1.addObject(MyButton, Caption="Hit me!", RegID="btn1")
                # Note that underscores *are* just fine in the RegID:
                btn2 = self.addObject(dabo.ui.dButton, Caption="Hello!", 
Top=100)
                btn2.RegID = "btn2_test_underscores"
@@ -34,11 +37,11 @@
        def onDeactivate(self, evt):
                print "MyForm.Deactivate"
 
-       def onHit_MyButton(self, evt):
-               print "onHit_MyButton"
+       def onHit_btn1(self, evt):
+               print "form: onHit_btn1"
 
        def onHit_btn2_test_underscores(self, evt):
-               print "onHit_btn2_test_underscores"
+               print "form: onHit_btn2_test_underscores"
 
 app.MainForm = MyForm()
 app.start()




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to