Could someone tell me why the following code doesn’t
show the bottom part of the toolbar icons on Windows? Almost all of the
icons are shown correctly, except for the very bottom of the bitmaps. This
code works great on Fedora Core, and is basically a copy of the code snippet in
the book wXIA. The bitmap filenames that I’m using in the code are “New.bmp”,
“Open.bmp”, and “Save.bmp”.
#!/usr/bin/env python
import wx
class MyGUI(wx.App):
def OnInit(self):
self.frame =
Frame(None, title = “MyGUI”, size = (400, 300))
self.frame.CenterOnScreen()
self.frame.Show()
self.SetTopWindow(self.frame)
return True
class Frame(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.init(self, *args, **kwargs)
self.createToolBar()
def createToolBar(self):
toolbar =
self.CreateToolBar()
for item in self.toolBarData():
self.createToolBarItems(toolbar, *item)
toolbar.Realize()
def createToolBarItems(self, toolbar,
tooltip, filename, status, handler):
if not tooltip:
toolbar.AddSeparator()
return
image =
wx.Image(filename, wx.BITMAP_TYPE_BMP).ConvertToBitmap()
toolBarItem =
toolbar.AddSimpleTool(wx.ID_ANY, image, tooltip, status)
self.Bind(wx.EVT_MENU, handler, toolBarItem)
def toolBarData(self):
“”"
Sets up the icons
to be placed inside of the toolbar using nested
tuples.
Each tuple represents a distinct tool in the toolbar.
Each nested tuple
consists of four parameters detailing the
tooltip, image
path/name, status bar message, and
event handler
method, respecively.
A separator line
is placed in the toolbar by inserting
("",
“”, “”) where desired on a line by itself in
“self.toolBarInfo”.
“”"
self.toolBarInfo
= (
("New",
“New.bmp”, “Create a new file”, self.onNew),
(“Open”, “Open.bmp”, “Open a new file to edit”,
self.onOpen),
(“Save”, “Save.bmp”, “Save file”, self.onSave),
("", “”, “”, “”),
)
return
self.toolBarInfo
def onNew(self, event):
pass
def onOpen(self, event):
pass
def onSave(self, event):
pass
def onSaveAs(self, event):
pass
def main():
app = MyGUI()
app.MainLoop()
if name == “main”:
main()