I borrowed an example code from here and altered it for my purpose:
import wx
def getBmp():
bmp = wx.EmptyBitmapRGBA(16,16, red=100, green=50, blue=50)
return bmp
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, style=wx.DEFAULT_FRAME_STYLE, parent=None)
self.SetTitle("why No image?")
menuBar = wx.MenuBar()
fileMenu = wx.Menu()
item = fileMenu.Append(wx.ID_NEW, "New")
item.SetBitmap(getBmp())
item = fileMenu.Append(wx.ID_OPEN, "Open")
item.SetBitmap(getBmp())
item = fileMenu.Append(wx.ID_SAVE, "Save")
item.SetBitmap(getBmp())
menuBar.Append(fileMenu, "File")
self.SetMenuBar(menuBar)
app = wx.PySimpleApp()
frame = MyFrame()
frame.Show()
app.SetTopWindow(frame)
app.MainLoop()
Problem: On my system configuration (Ubuntu 12.04 and wxPython 2.8.12.1) there is no icon/bitmap being displayed for any of the menu entries. No error messages except when I close down the window:
*(python:3321): LIBDBUSMENU-GLIB-WARNING ***: Trying to remove a child that doesn't believe we're it's parent.