Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > wxPython Menu problem

Reply
Thread Tools

wxPython Menu problem

 
 
linuxfreak
Guest
Posts: n/a
 
      07-18-2005
Hi all,

I have a problem. I want to add items to a Menu iteratively and I'm
stuck. Heres a snippet of my code

fileMenuChoices=[('&New','Start a New Document',self.onClick),

('&Open File...','Open an Existing Document',
self.onClick),

('&Save','Save Current Document', self.onClick),

('---'),

('E&xit','Close Window', self.onClick),

('&About','Information', self.onClick)]

......
......
......
......


fileMenu = wxMenu()
for opt in fileMenuChoices:
fmID = wxNewId()
if(opt[0] != '-'):
fileMenu.Append(fmID,opt[0], opt[1])
EVT_MENU(self,fmID,opt[2])
else:
fileMenu.AppendSeparator()
#Creating the MenuBar
menuBar = wxMenuBar()
menuBar.Append(fileMenu, "&File")
self.SetMenuBar(menuBar) #Add menubar to the Frame (Window)

def onClick(self,e):
.......
.......




The problem is I get an error saying name 'self' not defined...

Any help will be appreciated

 
Reply With Quote
 
 
 
 
ajikoe@gmail.com
Guest
Posts: n/a
 
      07-18-2005
try to check your definition of your function, self is usually used
inside a class.

pujo

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
wx/wxPython/wxPython.h & python24_d.lib problem Jolley Python 1 11-23-2006 08:02 AM
[wxPython-users] Web based applications are possible with wxPython? Ruben Charles Python 6 10-25-2005 09:41 PM
wxPython - wx package (new style wxPython?) Logan Python 5 12-11-2003 04:12 PM
[PY GUI] interest function in python GUI(wxpython,pyqt) program.wxpython,pyqt ulysses Python 4 10-22-2003 03:28 PM
wxPython looses function "wxPython.wx.miscc" Anand Python 1 07-23-2003 01:59 AM



Advertisments