In this wxPython article we want to learn about How to Create StatusBar in wxPython, status bar is commonly used graphical user interface element that provides important information about an application state. In wxPython creating a status bar is a simple process that involves using wx.StatusBar class.
First of all we need to import the required modules from wxPython.
1 |
import wx |
After that we creates the main frame of our application. this will serve as the container for the status bar and other GUI components, in the above code we creates the main frame of our application by inheriting from wx.Frame class. we set the title of the frame and its size. after that we defines the InitUI() method, and in that method we want to create the status bar using CreateStatusBar() method of the frame. we set the initial status text using SetStatusText() method of the status bar.
1 2 3 4 5 6 7 8 9 10 11 |
class MyApp(wx.Frame): def __init__(self, parent, title): super(MyApp, self).__init__(parent, title=title, size=(400, 300)) self.InitUI() def InitUI(self): statusBar = self.CreateStatusBar() statusBar.SetStatusText('Welcome to geekscoders.com') self.Show(True) |
To run the application we need to create an instance of our main frame class and start the wxPython event loop.
1 2 3 4 |
if __name__ == '__main__': app = wx.App() MyApp(None, 'StatusBar Example') app.MainLoop() |
This is the complete code for this article
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import wx import sys class MyApp(wx.Frame): def __init__(self, parent, title): super(MyApp, self).__init__(parent, title=title, size=(400, 300)) self.InitUI() def InitUI(self): statusBar = self.CreateStatusBar() statusBar.SetStatusText('Welcome to geekscoders.com') self.Show(True) if __name__ == '__main__': app = wx.App() MyApp(None, 'StatusBar Example') app.MainLoop() |
Run the code and this will be the result

You can learn more on wxPython