Although this bug is closed
[ 1422217 ] Menu problems - wxPython2.6-win32-ansi-2.6.2.1-py24,
I wanted to add this sample,
because I had written it before, so it
isn't for nothing, and one can check it again.
···
-------------------------------------------------------------------------------------------------
#with wxPython 2.6.0.0 it is working, also with 2.6.1.0
#import wxversion
#wxversion.select("2.6-msw-ansi")
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title)
menuBar = wx.MenuBar()
menu1 = wx.Menu()
#First problem
#if the menu is checked, the icon doesn't change
#instead of this, only the checkbox symbol is shown
item = wx.MenuItem(menu1, 500, "&Item Check", "", wx.ITEM_CHECK)
item.SetBitmaps(wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_TOOLBAR, (16,16)),
wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_TOOLBAR, (16,16)))
menu1.AppendItem(item)
#Second problem
#no submenu is shown
#instead of this, the submenu is placed into menu1 directly
submenu = wx.Menu()
submenu.Append(700, "Hi from submenu")
item = wx.MenuItem (menu1, 501, "Sub", "", subMenu = submenu)
item.SetBitmap(wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_TOOLBAR, (16,16)))
menu1.AppendItem (item)
menuBar.Append(menu1, "&Fun")
self.SetMenuBar(menuBar)
app = wx.App()
win = MyFrame(None, title="Small Menu Sample, wxPython Version: " + wx.VERSION_STRING)
win.Show()
app.MainLoop()
--
Franz Steinhaeusler