trouble with wxPython intro



I'm trying to learn WxPython with the tutorial:
http://wiki.wxpython.org/Getting_Started

But I can't seem to get the example for events to work. I pasted the
code they had directly into an interpreter and it got a dialog to
appear and the program was able to close itself, but my own copy won't
work. As far as I can see, it isn't at all different except for the
name of the main frame, and so I differ to you for help.

my own code:
#!/usr/bin/python

import wx

ID_ABOUT=101
ID_EXIT=110

class MainWindow(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,parent,id,title,size=(200,100))
self.control = wx.TextCtrl(self,1,style=wx.TE_MULTILINE)
self.CreateStatusBar() #adds a status bar to the bottom
#Menu setup
filemenu = wx.Menu()
filemenu.Append(wx.ID_ABOUT,"&About","Info about the program")
filemenu.AppendSeparator()
filemenu.Append(wx.ID_EXIT,"E&xit","Terminate the program.")
#Menubar setup
menuBar = wx.MenuBar()
menuBar.Append(filemenu,"&File") #add file to the menubar
self.SetMenuBar(menuBar) #add in the menubar
# Add events
wx.EVT_MENU(self,ID_ABOUT,self.OnAbout)

wx.EVT_MENU(self,ID_EXIT,self.OnExit)

# Go!
self.Show(True)
def OnAbout(self,e):
print "Show!"
d = wx.MessageDialog(self,"A sample editor.","About Sample
Ed",wx.OK)
d.ShowModal()
d.Destroy()
def OnExit(self,e):
print "close!"
self.Close(True)

app = wx.PySimpleApp()

frame = MainWindow(None,wx.ID_ANY,'Small Ed!')

app.MainLoop()

.



Relevant Pages

  • help with wxSlider & wxPython
    ... I have changed the background of the frame to ... # Creating the menubar. ... EVT_MENU# attach the menu-event ... def OnAbout: ...
    (comp.lang.python)
  • Re: Ruby oder Groovy fuer die Horizonterweiterung?
    ... interessantesten Konzepte von Groovy. ... Programmcode deklarativ erscheinen zu lassen. ... Oder muss man auch hier Dinge wie frame und ... menuBar implementieren. ...
    (de.comp.lang.java)
  • Strange menubar graphic artifact in frames created by applets
    ... When I create a frame from an applet and add a menubar, ... class MenuFrame extends Frame { ...
    (comp.lang.java.programmer)
  • Re: wxPython menu creation refactoring
    ... second for loop in "def createMenuData " creates a distinct ... menuBar = wx.MenuBar ... eachHandler), menuLabel) ... You create the submenu as a seperate menu then attach it to the ...
    (comp.lang.python)
  • menu-opened-p or something similar?
    ... Emacsen I re-wrote it to use timers instead of tracking the mouse. ... top of the frame. ... is expanded/opened and the timed function will then remove the menubar ... because in Gnu Emacs it returns the position relativ to the frame ...
    (comp.emacs.xemacs)