Better sys.path handling, other minor tweaks.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20373 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -23,10 +23,10 @@ immediately after a secondary prompt, like this:
|
|||||||
|
|
||||||
Added documentation files:
|
Added documentation files:
|
||||||
|
|
||||||
* MANUAL.txt (in py)
|
* PyManual.txt
|
||||||
* wxPython.txt (in py/wxd)
|
* wxPythonManual.txt
|
||||||
* wx.txt (in wx)
|
* wxPythonPackage.txt
|
||||||
* examples.txt (in wx/examples)
|
* wxPythonExamples.txt
|
||||||
|
|
||||||
Added PyAlaMode.py and PyAlaCarte code editors.
|
Added PyAlaMode.py and PyAlaCarte code editors.
|
||||||
|
|
||||||
@@ -42,6 +42,8 @@ Renamed program files:
|
|||||||
Removed disabling of autocomplete for lists of 2000 items or more. The
|
Removed disabling of autocomplete for lists of 2000 items or more. The
|
||||||
current implementation of wxSTC can now handle lists this big.
|
current implementation of wxSTC can now handle lists this big.
|
||||||
|
|
||||||
|
Improved handling of sys.path to mimic the standard Python shell.
|
||||||
|
|
||||||
|
|
||||||
0.9 (2/27/2003 to 3/20/2003)
|
0.9 (2/27/2003 to 3/20/2003)
|
||||||
============================
|
============================
|
||||||
|
@@ -32,12 +32,6 @@ class App(wx.wxApp):
|
|||||||
self.frame.SetSize((800, 600))
|
self.frame.SetSize((800, 600))
|
||||||
self.frame.Show()
|
self.frame.Show()
|
||||||
self.SetTopWindow(self.frame)
|
self.SetTopWindow(self.frame)
|
||||||
# Add the application object to the sys module's namespace.
|
|
||||||
# This allows a shell user to do:
|
|
||||||
# >>> import sys
|
|
||||||
# >>> sys.app.whatever
|
|
||||||
import sys
|
|
||||||
sys.app = self
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@@ -46,11 +40,13 @@ pycrust script that wxPython installs:
|
|||||||
|
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from wxPython.lib.PyCrust.PyCrustApp import main
|
from wx.py.PyCrust import main
|
||||||
main()
|
main()
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
"""The main function for the PyCrust program."""
|
||||||
|
# Cleanup the main namespace, leaving the App class.
|
||||||
import __main__
|
import __main__
|
||||||
md = __main__.__dict__
|
md = __main__.__dict__
|
||||||
keepers = original
|
keepers = original
|
||||||
@@ -58,11 +54,24 @@ def main():
|
|||||||
for key in md.keys():
|
for key in md.keys():
|
||||||
if key not in keepers:
|
if key not in keepers:
|
||||||
del md[key]
|
del md[key]
|
||||||
|
# Create an application instance.
|
||||||
app = App(0)
|
app = App(0)
|
||||||
|
# Mimic the contents of the standard Python shell's sys.path.
|
||||||
|
import sys
|
||||||
|
if sys.path[0]:
|
||||||
|
sys.path[0] = ''
|
||||||
|
# Add the application object to the sys module's namespace.
|
||||||
|
# This allows a shell user to do:
|
||||||
|
# >>> import sys
|
||||||
|
# >>> sys.app.whatever
|
||||||
|
sys.app = app
|
||||||
|
del sys
|
||||||
|
# Cleanup the main namespace some more.
|
||||||
if md.has_key('App') and md['App'] is App:
|
if md.has_key('App') and md['App'] is App:
|
||||||
del md['App']
|
del md['App']
|
||||||
if md.has_key('__main__') and md['__main__'] is __main__:
|
if md.has_key('__main__') and md['__main__'] is __main__:
|
||||||
del md['__main__']
|
del md['__main__']
|
||||||
|
# Start the wxPython event loop.
|
||||||
app.MainLoop()
|
app.MainLoop()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@@ -33,25 +33,21 @@ class App(wx.wxApp):
|
|||||||
self.frame.Show()
|
self.frame.Show()
|
||||||
self.SetTopWindow(self.frame)
|
self.SetTopWindow(self.frame)
|
||||||
self.frame.shell.SetFocus()
|
self.frame.shell.SetFocus()
|
||||||
# Add the application object to the sys module's namespace.
|
return True
|
||||||
# This allows a shell user to do:
|
|
||||||
# >>> import sys
|
|
||||||
# >>> sys.app.whatever
|
|
||||||
import sys
|
|
||||||
sys.app = self
|
|
||||||
return 1
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
The main() function needs to handle being imported, such as with the
|
The main() function needs to handle being imported, such as with the
|
||||||
pycrust script that wxPython installs:
|
pyshell script that wxPython installs:
|
||||||
|
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from wxPython.lib.PyCrust.PyCrustApp import main
|
from wx.py.PyShell import main
|
||||||
main()
|
main()
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
"""The main function for the PyShell program."""
|
||||||
|
# Cleanup the main namespace, leaving the App class.
|
||||||
import __main__
|
import __main__
|
||||||
md = __main__.__dict__
|
md = __main__.__dict__
|
||||||
keepers = original
|
keepers = original
|
||||||
@@ -59,11 +55,24 @@ def main():
|
|||||||
for key in md.keys():
|
for key in md.keys():
|
||||||
if key not in keepers:
|
if key not in keepers:
|
||||||
del md[key]
|
del md[key]
|
||||||
|
# Create an application instance.
|
||||||
app = App(0)
|
app = App(0)
|
||||||
|
# Cleanup the main namespace some more.
|
||||||
if md.has_key('App') and md['App'] is App:
|
if md.has_key('App') and md['App'] is App:
|
||||||
del md['App']
|
del md['App']
|
||||||
if md.has_key('__main__') and md['__main__'] is __main__:
|
if md.has_key('__main__') and md['__main__'] is __main__:
|
||||||
del md['__main__']
|
del md['__main__']
|
||||||
|
# Mimic the contents of the standard Python shell's sys.path.
|
||||||
|
import sys
|
||||||
|
if sys.path[0]:
|
||||||
|
sys.path[0] = ''
|
||||||
|
# Add the application object to the sys module's namespace.
|
||||||
|
# This allows a shell user to do:
|
||||||
|
# >>> import sys
|
||||||
|
# >>> sys.app.whatever
|
||||||
|
sys.app = app
|
||||||
|
del sys
|
||||||
|
# Start the wxPython event loop.
|
||||||
app.MainLoop()
|
app.MainLoop()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Reference in New Issue
Block a user