From: Alex T. <ale...@us...> - 2004-09-27 16:56:00
|
Update of /cvsroot/pythoncard/PythonCard/samples/testevents In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23237/samples/testevents Modified Files: testevents.py testevents.rsrc.py Log Message: Added example delayed events for child window opening (CallAfter, FutureCall) Index: testevents.rsrc.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/testevents/testevents.rsrc.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** testevents.rsrc.py 10 May 2004 05:02:44 -0000 1.5 --- testevents.rsrc.py 27 Sep 2004 16:55:49 -0000 1.6 *************** *** 1,53 **** ! { 'application':{ 'type':'Application', ! 'name':'TestEvents', ! 'backgrounds': ! [ ! { 'type':'Background', ! 'name':'bgMin', ! 'title':'Test Events PythonCard Application', ! 'size':( 300, 250 ), ! 'menubar': ! { ! 'type':'MenuBar', ! 'menus': ! [ ! { 'type':'Menu', ! 'name':'menuFile', ! 'label':'&File', ! 'items': [ ! { 'type':'MenuItem', ! 'name':'menuFileExit', ! 'label':'E&xit\tAlt+X', ! 'command':'exit', } ] } ! ] }, ! 'components': ! [ ! { 'type':'TextField', ! 'name':'fld', ! 'position':(0, 0), ! 'text':'Hello PythonCard' }, ! { 'type':'TextArea', ! 'name':'fldArea', ! 'position':(0, 30), ! 'size':(-1, 100), ! 'text':'The quick brown fox jumped over the lazy dog.' }, ! { 'type':'Button', ! 'name':'btn', ! 'position':(150, 0), ! 'label':'btn' }, ! { 'type':'Button', ! 'name':'cmdBtn', ! 'position':(150, 30), ! 'label':'cmdBtn', ! 'command':'setText' }, ! ] ! } ! ] ! } ! } --- 1,63 ---- + {'application':{'type':'Application', + 'name':'TestEvents', + 'backgrounds': [ + {'type':'Background', + 'name':'bgMin', + 'title':'Test Events PythonCard Application', + 'position':(488, 44), + 'size':(300, 250), ! 'menubar': {'type':'MenuBar', ! 'menus': [ ! {'type':'Menu', ! 'name':'menuFile', ! 'label':'&File', ! 'items': [ ! {'type':'MenuItem', ! 'name':'menuFileExit', ! 'label':'E&xit\tAlt+X', ! 'command':'exit', ! }, ! ] ! }, ! ] ! }, ! 'components': [ ! {'type':'Button', ! 'name':'childBtn', ! 'position':(149, 65), ! 'command':'openChildWindow', ! 'label':'childBtn', ! }, ! {'type':'TextField', ! 'name':'fld', ! 'position':(0, 0), ! 'text':'Hello PythonCard', }, ! {'type':'TextArea', ! 'name':'fldArea', ! 'position':(0, 30), ! 'size':(-1, 100), ! 'text':'The quick brown fox jumped over the lazy dog.', ! }, ! ! {'type':'Button', ! 'name':'btn', ! 'position':(150, 0), ! 'label':'btn', ! }, + {'type':'Button', + 'name':'cmdBtn', + 'position':(150, 30), + 'command':'openChildWindow', + 'label':'cmdBtn', + }, + + ] # end components + } # end background + ] # end backgrounds + } } Index: testevents.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/testevents/testevents.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** testevents.py 30 Apr 2004 23:02:39 -0000 1.20 --- testevents.py 27 Sep 2004 16:55:49 -0000 1.21 *************** *** 11,14 **** --- 11,24 ---- from PythonCard import model, timer + class MinimalChild(model.Background): + # creates a child window - using same resource file + # same appearance - but buttons and fields are not activated + def on_initialize(self, event): + print "initialize child window" + self.title = "Child Window" + + def callableFunction(self, stringParameter): + print "in child function", stringParameter + class Minimal(model.Background): *************** *** 143,146 **** --- 153,169 ---- event.skip() + def on_openChildWindow_command(self, event): + # delayed events - check the order these 'print's appear + # should be + # openChildWindow command + # leaving openCHildWindow + # initializing child window + # in child function via CallAfter + # in child function 10 ms in future + print "openChildWindow command", event.target.name + win = model.childWindow(self, MinimalChild) + wx.FutureCall(10, win.callableFunction, "10 ms in the Future") + wx.CallAfter(win.callableFunction, "via CallAfter") + print "leaving openChildWindow" if __name__ == '__main__': |