How do I insert a menu item in an existing menu.

BlueFlash ignace.danneels at
Wed Aug 26 23:40:24 CEST 2009

Idea:  Use of a RecentFileList, update element 0 with new file opened.

Appending a menu is easy
menu.Append(-1, "Menu Name")

when I try to insert a new menu item
menu.Insert(-1, position, "Menu Name")

does not work.

full code:
    def addnew(self, position, path):
        path = path.strip()
            self.filelist.index(path)     # index() throws ValueError
if path does not exist.
            # ValueError, path is not in list, so add it:
            if position >= len(self.filelist):
                item =, path)  #this does return a
menu item
                self.window.Bind(wx.EVT_MENU, self.event, item)
                self.filelist.insert(position, path)
                item =, position, path) # does
Not return a menu item.  throws some exception.
                print item
                #self.window.Bind(wx.EVT_MENU, self.event, item)

How do I remove a menu item from a menu?  The RecentUsedList is eg: 4
element long.  When opening a new file, this should be added at the
top, and the 4th element must be dropped.

More information about the Python-list mailing list