wxpython - passing arg to wx.app OnInit
Stuart McGraw
smcg4191zz at friizz.RimoovAllZZs.com
Sun Oct 23 14:07:39 EDT 2005
"Peter Hansen" <peter at engcorp.com> wrote in message news:7pGdnfmqQoJJG8beRVn-iA at powergate.ca...
> Stuart McGraw wrote:
> > I have a wxPython app, conventionally structured
> > with a Application class derived from wx.App.
> > My problem is that the app accepts a command
> > line argument that must be acted upon within the
> > OnInit() method of the Application class. How do
> > I pass it cleanly from main() into app.OnInit()? In
> > the simplified example below, dbfn is the piece of
> > info that is in main() that OnInit() needs to use.
> > Is a global variable is the only way? :-(
>
> There are various ways, but the simplest is to accept that sys.argv is
> *already* a "global" and just to access it directly from the
> Application's OnInit() method.
>
> This wiki page demonstrates:
> http://wiki.wxpython.org/index.cgi/UsingCommandLineArguments
>
> -Peter
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?
More information about the Python-list
mailing list