X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8dc6dcde52ed35b51e95db4a62060ade908a623b..bc93670d3b2b69ea2cdd799444b57dce24b8be94:/wxPython/demo/wxMenu.py diff --git a/wxPython/demo/wxMenu.py b/wxPython/demo/wxMenu.py index 2cb0ce60e1..7ee390800a 100644 --- a/wxPython/demo/wxMenu.py +++ b/wxPython/demo/wxMenu.py @@ -208,17 +208,26 @@ check the source for this sample to see how to implement them. def TestInsert(self, evt): + theID = 508 # get the menu mb = self.GetMenuBar() - menuItem = mb.FindItemById(507) + menuItem = mb.FindItemById(theID) menu = menuItem.GetMenu() + # figure out the position to insert at + pos = 0 + for i in menu.GetMenuItems(): + if i.GetId() == theID: + break + pos += 1 + + # now insert the new item ID = wxNewId() - ##menu.Insert(9, ID, "NewItem " + str(ID)) + ##menu.Insert(pos, ID, "NewItem " + str(ID)) item = wxMenuItem(menu) item.SetId(ID) item.SetText("NewItem " + str(ID)) - menu.InsertItem(9, item) + menu.InsertItem(pos, item)