diff --git a/wxPython/wxPython/py/CHANGES.txt b/wxPython/wxPython/py/CHANGES.txt index c02a22d01e..52e43f06eb 100644 --- a/wxPython/wxPython/py/CHANGES.txt +++ b/wxPython/wxPython/py/CHANGES.txt @@ -23,10 +23,10 @@ immediately after a secondary prompt, like this: Added documentation files: -* MANUAL.txt (in py) -* wxPython.txt (in py/wxd) -* wx.txt (in wx) -* examples.txt (in wx/examples) +* PyManual.txt +* wxPythonManual.txt +* wxPythonPackage.txt +* wxPythonExamples.txt 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 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) ============================ diff --git a/wxPython/wxPython/py/PyCrust.py b/wxPython/wxPython/py/PyCrust.py index 3ecd5b1184..dd6d144c80 100755 --- a/wxPython/wxPython/py/PyCrust.py +++ b/wxPython/wxPython/py/PyCrust.py @@ -32,12 +32,6 @@ class App(wx.wxApp): self.frame.SetSize((800, 600)) self.frame.Show() 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 ''' @@ -46,11 +40,13 @@ pycrust script that wxPython installs: #!/usr/bin/env python - from wxPython.lib.PyCrust.PyCrustApp import main + from wx.py.PyCrust import main main() ''' def main(): + """The main function for the PyCrust program.""" + # Cleanup the main namespace, leaving the App class. import __main__ md = __main__.__dict__ keepers = original @@ -58,11 +54,24 @@ def main(): for key in md.keys(): if key not in keepers: del md[key] + # Create an application instance. 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: del md['App'] if md.has_key('__main__') and md['__main__'] is __main__: del md['__main__'] + # Start the wxPython event loop. app.MainLoop() if __name__ == '__main__': diff --git a/wxPython/wxPython/py/PyShell.py b/wxPython/wxPython/py/PyShell.py index ed3ceeefef..845a17b977 100755 --- a/wxPython/wxPython/py/PyShell.py +++ b/wxPython/wxPython/py/PyShell.py @@ -33,25 +33,21 @@ class App(wx.wxApp): self.frame.Show() self.SetTopWindow(self.frame) self.frame.shell.SetFocus() - # 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 1 + return True ''' 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 - from wxPython.lib.PyCrust.PyCrustApp import main + from wx.py.PyShell import main main() ''' def main(): + """The main function for the PyShell program.""" + # Cleanup the main namespace, leaving the App class. import __main__ md = __main__.__dict__ keepers = original @@ -59,11 +55,24 @@ def main(): for key in md.keys(): if key not in keepers: del md[key] + # Create an application instance. app = App(0) + # Cleanup the main namespace some more. if md.has_key('App') and md['App'] is App: del md['App'] if md.has_key('__main__') and md['__main__'] is __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() if __name__ == '__main__':