Skip to content
Related Articles

Related Articles

Improve Article

wxPython – GetStatusText() function in wx.StatusBar

  • Last Updated : 09 Jul, 2020

In this article we are going to learn about GetStatusText() function associated with wx.StatusBar class of wxPython. GetStatusText() function is one of the most useful method in wx.StatusBar as this function returns the string associated with a status bar field.
It only takes single argument the number of the status field to retrieve, starting from zero.

Syntax: wx.StatusBar.GetStatusText(self, i=0)


ParameterInput TypeDescription
iintThe number of the status field to retrieve, starting from zero.

Returns: The status field string if the field is valid, otherwise the empty string.

Return Type: string

Code Example:

import wx
class Example(wx.Frame):
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        self.statusbar = wx.StatusBar()
        self.statusbar.Create(self, id = 1, style = wx.STB_DEFAULT_STYLE, 
                                                    name = "Status Bar")
        self.SetSize((350, 250))
        self.statusbar.SetStatusWidths([150, 150])
        self.statusbar.SetStatusText("This is first field", 0)
        self.statusbar.SetStatusText("This is second field", 1)
        self.statusbar.SetStatusStyles(styles =[wx.SB_RAISED, wx.SB_SUNKEN])
        print("First Field Text: "+self.statusbar.GetStatusText(0))
        print("Second Field Text: "+self.statusbar.GetStatusText(1))
        self.SetTitle('New Frame Title')
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':

Console Output:

First Field Text: This is first field
Second Field Text: This is second field

Output Window:

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :