In this article we are going to learn about SetStatusText() function associated with wx.StatuBar class of wxPython. SetStatusText() function is simply used to set the status text for the i-th field.
The given text will replace the current text. The display of the status bar is updated immediately, so there is no need to call wx.Window.Update after calling this function.
Syntax: wx.StatuBar.SetStatusText(self, text, i=0)
Parameters:
Parameter Input Type Description text string The text to be set. Use an empty string (“”) to clear the field. i int The field to set, starting from zero.
Code Example:
import wx class Example(wx.Frame): def __init__( self , * args, * * kwargs): super (Example, self ).__init__( * args, * * kwargs) self .InitUI() def InitUI( self ): self .locale = wx.Locale(wx.LANGUAGE_ENGLISH) self .statusbar = wx.StatusBar() self .statusbar.Create( self , id = 1 , name = "Status Bar" ) self .SetStatusBar( self .statusbar) self .SetSize(( 350 , 250 )) # SET TOTAL NUMBER OF FIELDS AND RESPECTIVE WIDTHS self .statusbar.SetFieldsCount( 3 , [ 100 , 80 , 60 ]) # SET TEXT FOR ALL FIELDS self .statusbar.SetStatusText( "Field One" , 0 ) self .statusbar.SetStatusText( "Field Two" , 1 ) self .statusbar.SetStatusText( "Field Three" , 2 ) self .SetTitle( 'New Frame Title' ) self .Centre() print ( self .statusbar.GetMinHeight()) def main(): app = wx.App() ex = Example( None ) ex.Show() app.MainLoop() if __name__ = = '__main__' : main() |
Output Window: