我刚刚开始使用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()
答案 0 :(得分:0)
你的代码在我的windows8上使用wxpython 3.0正常工作。试试这段代码:
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()