In code snippet, there is an example with, but there is only one command in menu. I need moore

menu = wx.Menu()#create_menu
        menu2 =wx.Menu()#menu2
        menu2.Append(wx.ID_EXIT, u"Add")#menu2
        self.Bind(wx.EVT_MENU, self.a, id=wx.ID_EXIT) #menu2
        menu.Append(wx.ID_EXIT, u"Přidat")#menu

        self.Bind(wx.EVT_MENU, self.Pridat, id=wx.ID_EXIT)#menu 
        menuBar.Append(menu2, "File")#menu2
        menuBar.Append(menu, "Soubor")#menu

it doesn't work correct
If do i presss Add or Pridat is called function self.Pridat. Correctly if i press Add it will call function self.a
please help

Here is a typical example of a wx.Menu() ...

# a wxPython Frame with menu, statusbar and about dialog

import wx
import os

# give the ids a unique integer value
ID_ABOUT = 101
ID_OPEN  = 102
ID_EXIT  = 103

class MyFrame(wx.Frame):
    """frame with menu, statusbar and about dialog, inherits wx.Frame"""
    def __init__(self):
        # create a frame, no parent, default to wxID_ANY
        wx.Frame.__init__(self, None, wx.ID_ANY, 'wxPython', pos=(300, 150), size=(300, 350))
        self.SetStatusText("This is a statusbar")
        menu = wx.Menu()
        # information string shows up in statusbar
        menu.Append(ID_ABOUT, "About", "Information about this program")
        menu.Append(ID_OPEN, "Open", "Open a file")
        menu.Append(ID_EXIT, "Exit", "Quit the program")
        menuBar = wx.MenuBar()
        menuBar.Append(menu, "File")
        self.Bind(wx.EVT_MENU, self.menuAbout, id=ID_ABOUT)
        self.Bind(wx.EVT_MENU, self.menuOpen, id=ID_OPEN)
        self.Bind(wx.EVT_MENU, self.menuExit, id=ID_EXIT)

        # show the frame
    def menuAbout(self, event):
        dlg = wx.MessageDialog(self,
            "a simple application using wxFrame, wxMenu\n"
            "a statusbar, and an about message dialog.",
            "About", wx.OK | wx.ICON_INFORMATION)
    def menuOpen(self,e):
        """open a file"""
        self.dirname = ''
        fileType = "Python files (.py)|*.py|Text files (.txt)|*.txt"
        dlg = wx.FileDialog(self, "Choose a file", self.dirname, "", fileType, wx.OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            self.filename = dlg.GetFilename()
            self.dirname = dlg.GetDirectory()
            self.full_path =  os.path.join(self.dirname, self.filename)
            print self.full_path  # test

    def menuExit(self, event):

application = wx.PySimpleApp()
# call class MyFrame
window = MyFrame()
# start the event loop

... hope it helps!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.