473,395 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

wxPython Menu problem

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

Jul 21 '05 #1
1 1291
try to check your definition of your function, self is usually used
inside a class.

pujo

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: ulysses | last post by:
hi, I'm working in python 5 months. I think it's very cool language. I do a p2p python program GUI. First I make a software by wxpython. But I find wxpython use many many memory. Second I use...
1
by: Curzio Basso | last post by:
Hi all, I have a problem for which I wasn't able to find an answer anywhere else, maybe someone can give me a hint... I designed with XRCed a small GUI (the code is at the bottom of the...
1
by: flupke | last post by:
Hi, i'm trying to convert my java console app to a python gui. Now, the only problem i seem to have at the moment are the resizers for the layout. It seems that for the purpose of what i'm...
6
by: OKB (not okblacke) | last post by:
I've started taking a look at wxPython, and, well, I've noticed that the syntax needed to code with it is extremely ugly. I am wondering if there exist any preprocessing tools or clever...
1
by: marchew | last post by:
hi, i have a problem integrating wxPython and Twisted under Win32. my application consumes 40-50% of CPU resources when wxFrame is visible and reactor (twisted) is running. i looked at...
1
by: mdk.R | last post by:
Hello all: i'am installed wxPython 2.5 and Python2.3.4..i try execute script with wxPython but it show error: Traceback (most recent call last): File "E:\py\test.py", line 7, in ? import wx...
2
by: rodmc | last post by:
I am totally new to Python and WxPython and need to write an application which can open up an external windows from a plug-in within GAIM (using pyGAIM). I have managed to hack some code together...
3
by: John Salerno | last post by:
I'm using the sample code of the file 'simple.py' and trying to make a single window with a panel in it, but I keep getting an error. Here's my code: (I know I might need something else, like a...
1
by: kath | last post by:
Hello, sorry about the lengthy message. I finding difficult to execute this program. The wx.Notebook i created is coming on the splitted frame(self.p2). How do I that. I am started to learn...
3
by: Netwatcher | last post by:
im try to activate the tutorial code for wxPython, it is working properly when i tell it to import * from wxPython.wx but with an error about the package, i've done as i was told to change the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.