Reputation: 4768
I am trying to teach myself wxPython, but I am driving myself batty trying to figure out why the standard menu icons aren't working. I am using Python 2.7.3 and wxPython 2.8.12.1 on Windows 7. When I use the code directly from the ZetCode tutorial, copied below for simplicity, I don't get any icons or standard icons showing in my menu
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
ZetCode wxPython tutorial
This example shows a simple menu.
author: Jan Bodnar
website: www.zetcode.com
last modified: September 2011
'''
import wx
class Example(wx.Frame):
def __init__(self, *args, **kwargs):
super(Example, self).__init__(*args, **kwargs)
self.InitUI()
def InitUI(self):
menubar = wx.MenuBar()
fileMenu = wx.Menu()
fitem = fileMenu.Append(wx.ID_EXIT, 'Quit', 'Quit application')
menubar.Append(fileMenu, '&File')
self.SetMenuBar(menubar)
self.Bind(wx.EVT_MENU, self.OnQuit, fitem)
self.SetSize((300, 200))
self.SetTitle('Simple menu')
self.Centre()
self.Show(True)
def OnQuit(self, e):
self.Close()
def main():
ex = wx.App()
Example(None)
ex.MainLoop()
if __name__ == '__main__':
main()
According to the tutorial, I should get something like this:
Instead, I'm getting this:
Is this due to a difference between Linux and Windows? Is there any way to get this to work without creating my own icons for each menu item?
Upvotes: 2
Views: 1302
Reputation: 11
I've also faced with same issue. According to documentation: "wx.ICON_QUESTION: Displays a question mark symbol. This icon is automatically used with YES_NO so it’s usually unnecessary to specify it explicitly. This style is not supported for message dialogs under wxMSW when a task dialog is used to implement them (i.e. when running under Windows Vista or later) because Microsoft guidelines indicate that no icon should be used for routine confirmations. If it is specified, no icon will be displayed"
Upvotes: -1
Reputation: 33091
The difference is that Windows doesn't have a default icon for exit. The wxPython toolkit wraps the native widgets so that the look and feel is correct across all operating systems. So yes, if you want an icon on Windows, you'll have to set it yourself.
Upvotes: 3