ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> pythoncard
pythoncard
[Pythoncard-users] Passing parameters to childwindow
by Kc106 2005-Pythoncard other posts by this author
Nov 10 2006 12:26PM messages near this date
[Pythoncard-users] Stupid question execute pythoncard in linux | Re: [Pythoncard-users] Passing parameters to childwindow
On the age old issue of passing parameters to childwindow, I think it's rather confusing tha
t we have to rely on "trick" to do it.  See, for example:

http://wiki.wxpython.org/index.cgi/PythonCardTricks

where it was suggested that we use the rather unnatural and "magical" way of:

def on_Button1_mouseClick(self, event):
   self.childWin = model.ChildWindow(self, bar.Bar)
   self.childWin.dbNamePassedFromParent = self.databaseName
Instead of doing that, is there anything wrong if I pass down a CallBackFunction such as:

    def on_Button1_mouseClick(self, event):
        self.childWin = model.childWindow(self, tchild, SetInitParamFct=self.SetChildInitPar
am)
        pass
        
    def SetChildInitParam(self, childWindow):
         ...do what ever...
        pass

and then in childWindow, we allow an extra parameter:

def childWindow(parent, frameClass, filename=None, rsrc=None, SetInitParamFct=SetInitParam):
.....
    return frameClass(parent, rsrc.application.backgrounds[0], SetInitParamFct=SetInitParamF
ct)

and then invoke the call back function at the very end of the __init__ function of the Backg
round class:

class Background(Scriptable, wx.Frame, event.EventSource):

    def __init__(self, aParent, aBgRsrc, SetInitParamFct=SetInitParam):
         ....
          SetInitParamFct(self)
          return

Of course, I need a stub function somewhere in model.py in case the call back function was n
ot defined:

# Stub function for setting ChildWindow parameters

def SetInitParam(childWindow):

    pass

    
Does anybody know if there would be side-effects that I am not aware of?

With this approach, I don't need to remind myself how the event dispatcher works when I look
 at my own code few years down the road....



 
--
John Henry



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Pythoncard-users mailing list
Pythoncard-users@[...].net
https://lists.sourceforge.net/lists/listinfo/pythoncard-users
Thread:
Kc106 2005-Pythoncard
Kc106 2005-Pythoncard

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved