wxPython bug
时间:2010-04-06 来源:masonzhang
今天敲code 非常简单的一张图贴不上去 去问Google 大神原来是 bug 3年了还是没有改 服了
http://trac.wxwidgets.org/ticket/4011 bug 这里
how to 这里
1
This is a confirmed bug which appearently has been open for quite a while. After trying around a little bit, this workaround seems to do it:
import wx
def getBmp():
bmp = wx.EmptyBitmap(16,16)
return bmp
class MyFrame(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,parent,id,title)
#======================================加菜单
menuBar = wx.MenuBar()
fileMenu=wx.Menu()
tempitem = fileMenu.Append(-1,"X") # !!!
tempitem.SetBitmap(getBmp()) # !!!
item = fileMenu.Append(wx.ID_NEW, "New")
fileMenu.Remove(tempitem.GetId()) # !!!
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)
#=====================================stuff
self.SetMenuBar(menuBar)
self.Center()
self.Show()
app = wx.PySimpleApp()
MyFrame(None ,-1,'L5.py')
app.MainLoop()
Note that the position of the fileMenu.Remove call is the earliest position that works, but you can also move it to the bottom. HTH.
相关阅读 更多 +