wxDemo launcher & demo program (pyshell)

I've copied this from the pyShell demo program, in the Wx demo launcher.

I've saved this as a separate file and tried to run it.

import wx.py as py

···

#----------------------------------------------------------------------

intro = 'Welcome To PyCrust %s - The Flakiest Python Shell' % py.version.VERSION

def runTest(frame, nb, log):
    win = py.shell.Shell(nb, -1, introText=intro)
    return win

#----------------------------------------------------------------------

overview = py.shell.__doc__

if __name__ == '__main__':
    import sys,os
    import run
    run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])

But the run module cannot be imported.
This program only runs from the demo- but I dont understand why I cant
run it from the command line.

Tony Cappellini wrote:

I've copied this from the pyShell demo program, in the Wx demo launcher.

I've saved this as a separate file and tried to run it.

import wx.py as py

#----------------------------------------------------------------------

intro = 'Welcome To PyCrust %s - The Flakiest Python Shell' % py.version.VERSION

def runTest(frame, nb, log):
   win = py.shell.Shell(nb, -1, introText=intro)
   return win

#----------------------------------------------------------------------

overview = py.shell.__doc__

if __name__ == '__main__':
   import sys,os
   import run
   run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])

But the run module cannot be imported.

run.py is part of the demo. Copy that file to the same as your script. That module takes care of creating a wx.App and a frame the demo can run in (and possible some more).

Christian

Christian K. wrote:

Tony Cappellini wrote:

I've copied this from the pyShell demo program, in the Wx demo launcher.

I've saved this as a separate file and tried to run it.

But the run module cannot be imported.

run.py is part of the demo. Copy that file to the same as your script. That module takes care of creating a wx.App and a frame the demo can run in (and possible some more).

Or you can just as easily break all ties to the demo framework and just create your own frame to put the shell in, and create your own app.

import wx
import wx.py as py

intro = 'Welcome To PyCrust %s - The Flakiest Python Shell' % py.version.VERSION

app = wx.App(False)
frm = wx.Frame(None, title="Test PyShell", size=(600,400))
shell = py.shell.Shell(frm, -1, introText=intro)
frm.Show()
app.MainLoop()

Or this is a little more OO:

import wx
import wx.py as py

intro = 'Welcome To PyCrust %s - The Flakiest Python Shell' % py.version.VERSION

class ShellFrame(wx.Frame):
     def __init__(self, *args, **kw):
         wx.Frame.__init__(self, *args, **kw)
         self.shell = py.shell.Shell(self, -1, introText=intro)

app = wx.App(False)
frm = ShellFrame(None, title="Test PyShell", size=(600,400))
frm.Show()
app.MainLoop()

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!