I'm trying to create a wx.Menu that will be shared between a popup (called on right-click), and a sub menu accessible from the frame menubar. The following code demonstrates the problem.
If you open the "MENUsubmenu" from the menubar the item "asdf" is visible. If you right click on the frame content area, "asdf" will be visible from there as well... however, returning to the menubar, you will find that "MENUsubmenu" is vacant. Why is this happening and how can I fix it?
import wx
app = wx.PySimpleApp()
m = wx.Menu()
m.Append(-1, 'asdf')
def show_popup(evt):
''' R-click callback '''
f.PopupMenu(m, (evt.X, evt.Y))
f = wx.Frame(None)
f.SetMenuBar(wx.MenuBar())
frame_menu = wx.Menu()
f.MenuBar.Append(frame_menu, 'MENU')
frame_menu.AppendMenu(-1,'submenu', m)
f.Show()
f.Bind(wx.EVT_RIGHT_DOWN, show_popup)
app.MainLoop()
Interestingly, appending the menu to MenuBar works, but is not the behavior I want:
import wx
app = wx.PySimpleApp()
m = wx.Menu()
m.Append(-1, 'asdf')
def show_popup(evt):
f.PopupMenu(m, (evt.X, evt.Y))
f = wx.Frame(None)
f.SetMenuBar(wx.MenuBar())
f.MenuBar.Append(m, 'MENU')
f.Show()
f.Bind(wx.EVT_RIGHT_DOWN, show_popup)
app.MainLoop()