Skip to content
Related Articles

Related Articles

Improve Article

wxPython – SetStatusWidths() function in wx.StatusBar

  • Last Updated : 15 Jun, 2020

In this article we are going to learn about SetStatusWidths() function associated with wx.StatuBar class of wxPython. SetStatusWidths() function sets the widths of the fields in the status line.

There are two types of fields: fixed widths and variable-width fields. For the fixed-width fields you should specify their (constant) width in pixels. For the variable width fields, specify a negative number which indicates how the field should expand: the space left for all variable width fields is divided between them according to the absolute value of this number. A variable-width field with width of -2 gets twice as much of it as a field with width -1 and so on.

 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

Syntax: wx.StatuBar.SetStatusWidths(self, widths)


ParameterInput TypeDescription
widthslist of intsThe text to be set. Use an empty string (“”) to clear the field.
iintContains an array of n integers, each of which is either an absolute status field width in pixels if positive or indicates a variable width field if negative. The special value None means that all fields should get the same width.

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, name = "Status Bar")
        self.SetSize((350, 250))
        self.statusbar.SetStatusWidths([100, 80, 60])        
        self.statusbar.SetStatusText("Field One", 0)
        self.statusbar.SetStatusText("Field Two", 1)
        self.statusbar.SetStatusText("Field Three", 2)
        self.SetTitle('New Frame Title')
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':

Output Window:

My Personal Notes arrow_drop_up
Recommended Articles
Page :