HomeLanguageswxPython – SetFieldsCount() function in wx.StatusBar

wxPython – SetFieldsCount() function in wx.StatusBar

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 for the corresponding fields.

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

Parameters:

Parameter Input Type Description
number int The number of fields. If this is greater than the previous number, then new fields with empty strings will be added to the status bar.
widths list of ints An array of n integers interpreted in the same way as in SetStatusWidths.

Code Example: 

Python3




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:

 

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32688 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7057 POSTS0 COMMENTS
Nicole Veronica
12198 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12293 POSTS0 COMMENTS
Shaida Kate Naidoo
7182 POSTS0 COMMENTS
Ted Musemwa
7447 POSTS0 COMMENTS
Thapelo Manthata
7160 POSTS0 COMMENTS
Umr Jansen
7150 POSTS0 COMMENTS