wxPython Menu problem

L

linuxfreak

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
 
A

ajikoe

try to check your definition of your function, self is usually used
inside a class.

pujo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top