wxpython 菜单栏不显示 [英] wxpython menu bar not displaying

查看:47
本文介绍了wxpython 菜单栏不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 wxpython 为 gui 编写时间表程序,并且正在使用 wxpython wiki 上的入门教程来加快 wxpython 的速度,但是当我尝试向 wxFrame 添加菜单栏时,菜单栏没有展示.任何想法为什么会发生这种情况?我正在使用 ubuntu 10.10 和 python 2.7.代码如下:

I am trying to write a timetabling program using wxpython for gui and am using the getting started tutorial on the wxpython wiki to get up to speed with wxpython but when I try to add a menu bar to wxFrame, the menu bar does not show. Any ideas why this is happening? I am using ubuntu 10.10 and python 2.7. The code is given below:

#! /usr/bin/env python2.7
import wx, os

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


        # Creating the menubar.
        menuBar = wx.MenuBar()

         # Setting up the menu.
        filemenu= wx.Menu()

        # wx.ID_ABOUT and wx.ID_EXIT are standard ids provided by wxWidgets.
        menuAbout = filemenu.Append(wx.ID_ABOUT, "&About"," Information about this program")
        menuExit = filemenu.Append(wx.ID_EXIT,"E&xit"," Terminate the program")

        menuBar.Append(filemenu,"&File") # Adding the "filemenu" to the MenuBar
        self.SetMenuBar(menuBar)  # Adding the MenuBar to the Frame content.

        # Set events.
        self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout)
        self.Bind(wx.EVT_MENU, self.OnExit, menuExit)

        self.Show(True)


    def OnAbout(self,e):

        # A message dialog box with an OK button. wx.OK is a standard ID in wxWidgets.
        dlg = wx.MessageDialog( self, "A small text editor", "About Sample Editor", wx.OK)
        dlg.ShowModal() # Show it
        dlg.Destroy() # finally destroy it when finished.

    def OnExit(self,e):
        self.Close(True)  # Close the frame.
        ''' 
        # 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()

推荐答案

有人在 wxPython 列表中遇到了类似的问题.我认为菜单出现在任务栏"或其他东西中,因为操作系统已经为此进行了配置,有点像 Mac.如果您使用的是自定义主题,请尝试使用标准主题.您也可以尝试运行 wxPython 演示,看看它是否有同样的问题.

Someone had a similar issue on the wxPython list. I think the menu was appearing in the "taskbar" or something because the OS had been configured for that, kind of like a Mac. If you're using a custom theme, try a standard one instead. You can also try running the wxPython demo to see if it has the same issue.

这篇关于wxpython 菜单栏不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆