Better scripting support.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20288 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,7 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from wx.py.PyWrap import main
|
from wx.py.PyWrap import main
|
||||||
import sys, os
|
main()
|
||||||
|
|
||||||
sys.path.insert(0, os.curdir)
|
|
||||||
main(sys.argv)
|
|
||||||
|
@@ -32,11 +32,12 @@ class App(wx.wxApp):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def main(filename=None):
|
def main(filename=None):
|
||||||
|
if not filename and len(sys.argv) > 1:
|
||||||
|
filename = sys.argv[1]
|
||||||
|
if filename:
|
||||||
|
filename = os.path.realpath(filename)
|
||||||
app = App(filename)
|
app = App(filename)
|
||||||
app.MainLoop()
|
app.MainLoop()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
filename = None
|
main()
|
||||||
if len(sys.argv) > 1:
|
|
||||||
filename = os.path.realpath(sys.argv[1])
|
|
||||||
main(filename)
|
|
||||||
|
@@ -32,11 +32,12 @@ class App(wx.wxApp):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def main(filename=None):
|
def main(filename=None):
|
||||||
|
if not filename and len(sys.argv) > 1:
|
||||||
|
filename = sys.argv[1]
|
||||||
|
if filename:
|
||||||
|
filename = os.path.realpath(filename)
|
||||||
app = App(filename)
|
app = App(filename)
|
||||||
app.MainLoop()
|
app.MainLoop()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
filename = None
|
main()
|
||||||
if len(sys.argv) > 1:
|
|
||||||
filename = os.path.realpath(sys.argv[1])
|
|
||||||
main(filename)
|
|
||||||
|
@@ -26,14 +26,16 @@ def wrap(app):
|
|||||||
app.MainLoop()
|
app.MainLoop()
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(modulename=None):
|
||||||
if len(argv) < 2:
|
sys.path.insert(0, os.curdir)
|
||||||
|
if not modulename:
|
||||||
|
if len(sys.argv) < 2:
|
||||||
print "Please specify a module name."
|
print "Please specify a module name."
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
name = argv[1]
|
modulename = sys.argv[1]
|
||||||
if name[-3:] == '.py':
|
if modulename.endswith('.py'):
|
||||||
name = name[:-3]
|
modulename = modulename[:-3]
|
||||||
module = __import__(name)
|
module = __import__(modulename)
|
||||||
# Find the App class.
|
# Find the App class.
|
||||||
App = None
|
App = None
|
||||||
d = module.__dict__
|
d = module.__dict__
|
||||||
@@ -51,5 +53,4 @@ def main(argv):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.path.insert(0, os.curdir)
|
|
||||||
main(sys.argv)
|
main(sys.argv)
|
||||||
|
Reference in New Issue
Block a user