Skip to content
Related Articles

Related Articles

Improve Article

wxPython – SetFieldsCount() function in wx.StatusBar

  • Last Updated : 12 Jun, 2020

In this article we are going to learn about SetFieldsCount() function associated with wx.StatusBar class of wxPython. SetFieldsCount() function is simply used to set the number of fields, and optionally the field widths.
It takes two parameters number of Field to be set and list of widths forthe corresponding fields.

Syntax: wx.StatusBar.SetFieldsCount(self, number=1, widths=None)

Parameters:

ParameterInput TypeDescription
numberintThe number of fields. If this is greater than the previous number, then new fields with empty strings will be added to the status bar.
widthslist of intsAn array of n integers interpreted in the same way as in SetStatusWidths.

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, style = wx.STB_DEFAULT_STYLE,
                                                     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()
  
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()

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 :