【发布时间】:2016-01-01 16:31:39
【问题描述】:
import wx
class MainWindow(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title, size=(200,100))
self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
self.CreateStatusBar() # A Statusbar in the bottom of the window
# Setting up the menu.
filemenu= wx.Menu()
# wx.ID_ABOUT and wx.ID_EXIT are standard IDs provided by wxWidgets.
filemenu.Append(wx.ID_ABOUT, "&About"," Information about this program")
filemenu.AppendSeparator()
filemenu.Append(wx.ID_EXIT,"E&xit"," Terminate the program")
# Creating the menubar.
menuBar = wx.MenuBar()
menuBar.Append(filemenu,"&File") # Adding the "filemenu" to the MenuBar
self.SetMenuBar(menuBar) # Adding the MenuBar to the Frame content.
self.Show(True)
app = wx.App(False)
frame = MainWindow(None, "Sample editor")
app.MainLoop()
我可以看到 &File 菜单,但它是空的。它不包含 about 和 exit 项。我在这里错过了什么?
这是带有代码的原始 wiki 页面:wxPython wiki
非常感谢。
另外:如果我将 ID_ABOUT 和 ID_EXIT 替换为一些随机数,它就可以工作。无论如何,我不想这样做,因为这不是标准方式。
【问题讨论】:
-
我在 python2.7..(Debian Jessie Linux) 上工作得很好............使用了 ID_ABOUT 和 ID_EXIT....hmmm..
-
我认为这个问题与MacOSX严格相关..这里是Python2.7.10