WxPython questions.

Omri Schwarz ocschwar at mit.edu
Fri Jun 15 04:54:15 EDT 2001


I am teaching myself Python and wxPython
(unless you tell me to "get out, get out while you 
still can" on the latter of the two)

and am trying to run the program in the wxPython
tutorial:

http://www.wxpython.org/tut-part1.php

The first example works, but the second gives me these errors
when I try to run it interactively (works fine when I save to
a file 'foo' and do 'python foo'). (Errors are below.)

So my question is, is there a more interactive way to 
play around with wxPython?



__ begin errors from interactive session:


[omri at percy-hobbs omri]$ python
Python 2.1 (#1, Apr 20 2001, 20:30:42) 
[GCC 2.95.3 20010315 (release)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> from wxPython.wx import *
>>> 
>>> ID_ABOUT = 101
>>> ID_EXIT  = 102
>>> 
>>> class MyFrame(wxFrame):
...     def __init__(self, parent, ID, title):
...         wxFrame.__init__(self, parent, ID, title,
...                          wxDefaultPosition, wxSize(200, 150))
...         self.CreateStatusBar()
...         self.SetStatusText("This is the statusbar")
... 
>>>         menu = wxMenu()
  File "<stdin>", line 1
    menu = wxMenu()
    ^
SyntaxError: invalid syntax
>>>         menu.Append(ID_ABOUT, "&About",
  File "<stdin>", line 1
    menu.Append(ID_ABOUT, "&About",
    ^
SyntaxError: invalid syntax
>>>                     "More information about this program")
  File "<stdin>", line 1
    "More information about this program")
    ^
SyntaxError: invalid syntax
>>>         menu.AppendSeparator()
  File "<stdin>", line 1
    menu.AppendSeparator()
    ^
SyntaxError: invalid syntax
>>>         menu.Append(ID_EXIT, "E&xit", "Terminate the program")
  File "<stdin>", line 1
    menu.Append(ID_EXIT, "E&xit", "Terminate the program")
    ^
SyntaxError: invalid syntax
>>> 
>>>         menuBar = wxMenuBar()
  File "<stdin>", line 1
    menuBar = wxMenuBar()
    ^
SyntaxError: invalid syntax
>>>         menuBar.Append(menu, "&File");
  File "<stdin>", line 1
    menuBar.Append(menu, "&File");
    ^
SyntaxError: invalid syntax
>>> 
>>>         self.SetMenuBar(menuBar)
  File "<stdin>", line 1
    self.SetMenuBar(menuBar)
    ^
SyntaxError: invalid syntax
>>> 
>>> 
>>> class MyApp(wxApp):
...     def OnInit(self):
...         frame = MyFrame(NULL, -1, "Hello from wxPython")
...         frame.Show(true)
self.SetTopWindow(frame)
...         return true
... 
>>> app = MyApp(0)
>>> app.MainLoop()
>>> 




-- 
Omri Schwarz --- ocscwar at mit.edu ('h' before war) 
Timeless wisdom of biomedical engineering: "Noise is principally
due to the presence of the patient." -- R.F. Farr




More information about the Python-list mailing list