wxpython - passing arg to wx.app OnInit

Peter Hansen peter at engcorp.com
Sun Oct 23 20:58:07 CEST 2005

Stuart McGraw wrote:
> I simplied the my code for posting.  In my real program, the
> thing being passed is not a command line argument per se,
> but the result of signifigant processing dependent on the 
> command line argument.  I do not want to repeat that 
> processing in the wx.App method.
> Would you elaborate on the other ways?

In that case, override __init__ something like this:

class Application(wx.App):
    def __init__(self, *pargs, clargs=None, **kwargs):
        self.clargs = clargs or []   # store reference to args

        # call parent class initializer
        wx.App.__init__(self, *pargs, **kwargs)

   def OnInit(self):
       # use self.clargs here

app = Application(redirect=0, clargs=[dbfn])

or whatever... I just guessed at what you meant to do with dbfn though,
but I think the basic idea is clear enough.


More information about the Python-list mailing list