wxPython Menu problem

Discussion in 'Python' started by linuxfreak, Jul 18, 2005.

  1. linuxfreak

    linuxfreak Guest

    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
    linuxfreak, Jul 18, 2005
    #1
    1. Advertising

  2. linuxfreak

    Guest

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

    pujo
    , Jul 18, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anand
    Replies:
    1
    Views:
    344
    Cliff Wells
    Jul 23, 2003
  2. ulysses
    Replies:
    4
    Views:
    757
    Werner Schiendl
    Oct 22, 2003
  3. Logan
    Replies:
    5
    Views:
    753
    David Bolen
    Dec 11, 2003
  4. Ruben Charles
    Replies:
    6
    Views:
    493
    =?ISO-8859-1?Q?Michael_Str=F6der?=
    Oct 25, 2005
  5. Jolley
    Replies:
    1
    Views:
    1,186
    Jolley
    Nov 23, 2006
Loading...

Share This Page