PyQt status bar

A status bar can be added to a PyQt window. The main window has its own layout for QMenuBar, QToolBar, QDockWidget, and QStatusBar. It also has an area in the center area for widgets.

You can use the QMainWindow class to create the main application window.

Related course: Create Desktop Apps with Python PyQt5

QStatusBar

First, let's use the QStatusBar to create a status bar in the main window. The status bar is a widget located at the bottom of the application to tell you the status of the application.

Use the showMessage() method to display text in the status bar.

If you want the text to disappear, you can use the clearMessage() method or set the time at which the text appears in the showMessage() method.

The QStatusBar class has a messageChanged() signal every time the message displayed in the status bar changes.

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow

class MyApp(QMainWindow):

def __init__(self):
        super().__init__()
        self.initUI()

def initUI(self):
        self.statusBar().showMessage('Ready')

self.setWindowTitle('Statusbar')
        self.setGeometry(300, 300, 300, 200)
        self.show()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = MyApp()
    sys.exit(app.exec_())

You will now see a status bar at the bottom of the application window.

statusbar pyqt

Related course: Create Desktop Apps with Python PyQt5

Description

self.statusBar().showMessage('Ready')

The status bar is created using the statusBar() method of the QMainWindow class, which is created by calling the statusBar() method for the first time. The next call returns the status bar object. The showMessage() method allows you to set the message to be shown in the status bar.