gpt4 book ai didi

python - Wx Python : Status Bar Does Not Show Menu Messages

转载 作者:太空宇宙 更新时间:2023-11-03 12:07:35 30 4
gpt4 key购买 nike

我刚开始使用 wx python,我无法让状态栏显示菜单项的帮助文本。我读到可以使用 SetStatusText() 设置状态栏消息,但我想要显示这样的帮助文本。我正在使用 Ubuntu 14.04/wxPython 2.8/Python 2.7.6。请帮忙。提前致谢。

import wx

class Test(wx.Frame):

def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,"Frame aka Window",size = (300,200))
panel = wx.Panel(self)

self.status=self.CreateStatusBar()
#self.status.SetStatusText("Something")
menubar=wx.MenuBar()

first=wx.Menu()
second=wx.Menu()

first.Append(wx.NewId(),"New Window","This is a new window")
first.Append(wx.NewId(),"Open...","Open A New Window")
menubar.Append(first,"File")
menubar.Append(second,"Edit")
self.SetMenuBar(menubar)



if __name__=='__main__':
app=wx.PySimpleApp()
frame=Test(None,id=-1)
frame.Show()
app.MainLoop()

最佳答案

您的代码在我的 wxpython 3.0 windows8 上运行良好。试试这个代码:

import wx
class Test( wx.Frame ):

def __init__( self, parent ):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = "Frame aka Window", pos = wx.DefaultPosition, size = wx.Size( 300,200 ), style = wx.DEFAULT_FRAME_STYLE )

self.panel = wx.Panel(self)
self.status = self.CreateStatusBar( 1, 0, wx.ID_ANY )

self.menu = wx.MenuBar( 0 )
self.first = wx.Menu()
self.new = wx.MenuItem( self.first, wx.ID_ANY, "New Window", u"This is a new window", wx.ITEM_NORMAL )
self.first.AppendItem( self.new )
self.open = wx.MenuItem( self.first, wx.ID_ANY, "Open", u"Open a new window", wx.ITEM_NORMAL )
self.first.AppendItem( self.open )
self.menu.Append( self.first, "File" )
self.second = wx.Menu()
self.menu.Append( self.second, "Menu" )
self.SetMenuBar( self.menu )
self.Centre( wx.BOTH )



if __name__=='__main__':
app=wx.App()
frame=Test(None)
frame.Show()
app.MainLoop()

关于python - Wx Python : Status Bar Does Not Show Menu Messages,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24444769/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com