Python Wx: Status Bar Does Not Display Menu Messages

I'm just starting out with wx python, and I can't get the status bar to display help text from menu items. I read that messages in the status bar can be set with SetStatusText(), but I want help texts like this to be displayed, I am using Ubuntu 14.04 / wxPython 2.8 / Python 2.7.6. Please help. Thanks in advance.

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()
+4
source share
1 answer

Your code worked fine on my windows8 using wxpython 3.0. Try this code:

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()
0
source

Source: https://habr.com/ru/post/1546243/


All Articles