【问题标题】:Running example code of wxpython but Menu Item does not show up运行 wxpython 的示例代码但菜单项不显示
【发布时间】: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

标签: macos wxpython


【解决方案1】:

This question 回答了我的问题。它在那里创建菜单项,但我没有注意到,因为我没有仔细检查。感谢任何对这个问题感兴趣的人

【讨论】:

  • 也在这里查看此链接..似乎股票 ID 仅适用于 OSX 上的应用程序菜单小部件....trac.wxwidgets.org/ticket/12092..not 确实是一个错误,但操作系统平台问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-11-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-02
  • 2011-02-24
相关资源
最近更新 更多