Skip to content
Advertisement

Show wx.MenuItems’s Help String in a determined wx.StatusBar’s Field

Premise:

I’m creating a little wx.Frame with a wx.StatusBar with 3 Fields, the one on the left and the one on the right smaller and the one on the center bigger.

Now, By Default, when i put the mouse on a wx.MenuItem the wx.StatusBar set as Status Text the wx.MenuItem’s Help String in the FIRST wx.StatusBar’s Field like in the below picture:

enter image description here

Question:

Now, I want, if it’s possible, that in the above situation the wx.MenuItem’s Help String in the SECOND FIELD (the biggest one in the center)

Advertisement

Answer

You are looking for SetStatusBarPane() for the frame
It simply requires you to nominate a pane number (from 0) where the text should be displayed.

enter image description here

import wx

class Test(wx.Frame):

    def __init__(self,parent):
        wx.Frame.__init__(self,parent,title="Frame aka Window",size = (300,200))
        panel = wx.Panel(self)
        self.status=self.CreateStatusBar(3)
        self.SetStatusBarPane(1)
        self.status.SetStatusText("Status bar 0",0)
        self.status.SetStatusText("Status bar 2",2)
        menubar=wx.MenuBar()
        firstm=wx.Menu()
        secondm=wx.Menu()

        fm1 = wx.MenuItem(firstm, wx.NewIdRef(), 'New WindowtAlt+N')
        firstm.Append(fm1)
        self.Bind(wx.EVT_MENU, self.OnMenu1, id=fm1.GetId())
        fm2 = wx.MenuItem(firstm, wx.NewIdRef(), 'Open', "Text for the statusbar")
        firstm.Append(fm2)
        self.Bind(wx.EVT_MENU, self.OnMenu2, id=fm2.GetId())
        fm3 = wx.MenuItem(firstm, -1, 'QuittAlt+Q')
        firstm.Append(fm3)
        self.Bind(wx.EVT_MENU, self.OnMenu3, id=fm3.GetId())

        sm1 = wx.MenuItem(firstm, wx.ID_ANY, 'Re-Do', "Statusbar Re-Do")
        secondm.Append(sm1)
        self.Bind(wx.EVT_MENU, self.OnsMenu1, id=sm1.GetId())
        sm2 = wx.MenuItem(secondm, wx.ID_ANY, 'Un-Do', "Statusbar Un-Do")
        secondm.Append(sm2)
        self.Bind(wx.EVT_MENU, self.OnsMenu2, id=sm2.GetId())

        menubar.Append(firstm,"File")
        menubar.Append(secondm,"Edit")

        self.SetMenuBar(menubar)

        t = wx.StaticText(panel,-1,"Hello i'm a test", pos=(10,20))

    def OnMenu1(self, event):
        print("Menu item 1",event.GetId())

    def OnMenu2(self, event):
        print("Menu item 2",event.GetId())
        
    def OnMenu3(self, event):
        print("Menu item 3 Quit",event.GetId())
        self.Destroy()
                
    def OnsMenu1(self, event):
        print("2nd Menu item 1",event.GetId())

    def OnsMenu2(self, event):
        print("2nd Menu item 2",event.GetId())

if __name__=='__main__':
    app=wx.App()
    frame=Test(None)
    frame.Show()
    app.MainLoop()
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement