2013-12-10 78 views
1

我想教自己wxPython,但我開車自己試圖找出爲什麼標準菜單圖標不工作。我在Windows 7上使用Python 2.7.3和wxPython的2.8.12.1當我使用直接從ZetCode tutorial的代碼,複製以下爲簡單起見,我沒有得到我的菜單顯示任何圖標或標準圖標wxPython標準菜單圖標和不顯示的快捷方式

#!/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() 

按照教程,我應該得到的東西是這樣的:

What I should be getting (sourced from zetcode)

相反,我得到這個:

enter image description here

這是由於Linux和Windows的區別嗎?有沒有辦法讓這個工作不需要爲每個菜單項創建我自己的圖標?

回答

2

區別在於Windows沒有退出的默認圖標。 wxPython工具包包裝本機窗口小部件,以便所有操作系統的外觀和感覺都是正確的。所以是的,如果你想在Windows上看到圖標,你必須自己設置。