Introduction
It's really easy to use command-line arguments in your app. Import sys and in your subclass of wxApp, just use sys.argv.
Code Sample
import wx import sys class MyApp(wx.App): def OnInit(self): args = sys.argv[1:] frame = wx.Frame(None, -1, "args = %s" % (args,)) frame.Show(True) self.SetTopWindow(frame) return True app = MyApp(0) app.MainLoop()
Then, at the command prompt:
prompt:chmod +x tmp.py prompt:./tmp.py test
Comments
Or, for more complex handling, use the Python getopt or optparse modules. - JohnFouhy
Comments
On Windows's command prompt, only
python UsingCommandLineArguments.py opt1 opt2
works, but not the direct call:
UsingCommandLineArguments.py opt1 opt2
- Franz Steinhaeusler