[wxPython-users] Re: wxDemo launcher & demo program (pyshell)

Robin Dunn robin at alldunn.com
Tue Jun 5 09:59:09 PDT 2007


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!





More information about the wxpython-users mailing list