Search code examples
python-2.7wxpython

wxMenu and submenus


it is known that wx.Menu.Append(wx.ID_ANY) returns and item and with a unique id within the Menu. is this true also with submenus in menus

generalMenu=wx.Menu()
item1 = generalMenu.Append(wx.ID_ANY, "item 1")
item2 = generalMenu.Append(wx.ID_ANY, "item 2")

subMenu=wx.Menu()
item3 = subMenu.Append(wx.ID_ANY, "item 1")
item4 = subMenu.Append(wx.ID_ANY, "item 2")

generalMenu.AppendSubMenu(subMenu, "Sub-menu")

Does wx insures that item1, item2, item3 and item4 have all different ids? or just within the same menu ?


Solution

  • Yes, they will be unique. wx.ID_ANY and wx.NewId() create id's that are globally unique within the application.

    (There is a max limit to these, and then it becomes a mess, but that's probably not a concern for this question.)