【发布时间】:2013-12-10 10:06:36
【问题描述】:
我正在尝试自学 wxPython,但我正在努力找出标准菜单图标不起作用的原因。我在 Windows 7 上使用 Python 2.7.3 和 wxPython 2.8.12.1。当我直接使用来自 ZetCode tutorial 的代码(为简单起见复制到下面)时,我的菜单中没有显示任何图标或标准图标
#!/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()
根据教程,我应该得到这样的东西:
相反,我得到了这个:
这是由于 Linux 和 Windows 之间的差异造成的吗?有什么方法可以在不为每个菜单项创建我自己的图标的情况下使其工作?
【问题讨论】:
标签: python python-2.7 wxpython