2011-03-10 19 views
0

下面的代碼段填充了一個繼承自類wx.Menu類的菜單項。所以自我基本上是一個wx.Menu。當我運行流動的代碼片段,行about.SetBitmap(wx.Bitmap(「Icon24.ico」))似乎高亮更改默認:影響Windows 7上wxPython中菜單樣式的圖標

enter image description here

這個普通的藍色風格:

enter image description here

about.SetBitmap(wx.Bitmap( 'Icon24.ico'))只是增加了一個圖標(測試)。但是,由於某種原因,它會改變突出顯示風格。我知道這是關於nitpicky,因爲它是,但我想第一個圖像突出顯示與第二個圖像圖標的風格。這是在Windows 7中,如果它有所作爲。

段:

about = wx.MenuItem(self, -1, 'About...') 
about.SetBitmap(wx.Bitmap('Icon24.ico')) # The line that's causing the problem. 

itemlist = [self.AppendItem(about), 
      self.AppendSeparator(), 
      self.Append(-1, 'Options...'), 
      self.AppendSeparator(), 
      self.Append(-1, 'Exit')] 

for i in itemlist: 
    self.Bind(wx.EVT_MENU, self.menu_beh, i) 
+0

您正在使用哪個版本的wxWidgets/wxPython? – Terseus 2011-03-10 09:13:31

+0

wxPython版本2.8.11.0,在Python 2.6.5 – rectangletangle 2011-03-10 10:25:03

回答

1

那麼,根據wxWidgets的文檔,版本2.8不支持Windows Vista或Windows 7,所以我覺得,因爲看起來它重置整個菜單主題,以這種預期XP風格,我認爲你可以嘗試的最好的方法是使用支持Vista(但不是7)的測試版本2.9。

+0

是的,這是它! 2.9正確顯示。 – rectangletangle 2011-03-10 11:38:47