From: Kevin A. <al...@ya...> - 2005-03-30 06:38:36
|
I'm still not sure on the best way to deal with the desire to pass args to a child window, but I would like to propose one possible solution as well as clarify some of the issues surrounding child windows. As a test, I duplicated the minimal source and resource and added the following test code. def on_initialize(self, event): print "child initialize" def postInit(self, a, b): print "postInit" print a, b I modified the minimal sample by adding a button and the following code to create the child window as well as call an additional method once the other events have fired by using wx.CallAfter. def on_btn_mouseClick(self, event): print "mouseClick" self.myChild = model.childWindow(self, minchild.Minimal) wx.CallAfter(self.myChild.postInit, "hello", 2) This appears to work as expected, but may not be what Liam and others are looking for. I'll let them reply with their current solutions and what they want. model.childWindow is just a convenience function. PythonCard does not use __init__ in user code since that can be a dangerous place for user code as you might try and access or modify controls or methods that have not finished initializing in wxWidgets/wxPython. Thus the initialize event has been the way of doing initialization and the "event" is supposed to fire after all other wx initialization is done and the underlying control or window has "settled", so it is safe to do whatever manipulations you need. Furthermore, initialize is an event in an attempt to be more consistent, but that means it only has one argument, "event", just like all the other events. In the case of the childWindow function, the initialize event that fires is disconnected from the function call. Even if *args and **kwargs arguments were used in the childWindow function I couldn't pass them to initialize in a clean way. Making a separate method call that you have control over when it happens in relation to other events seems like the simplest solution. Given that this might be a common need, maybe we should have a PythonCard alias for wx.CallAfter? Additional thoughts? I can dig into this issue more next week. ka __________________________________ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail |