
- PyQt - Home
- PyQt - Introduction
- PyQt - Environment
- PyQt - Hello World
- PyQt - Major Classes
- PyQt - Using Qt Designer
- PyQt - Meta Objects
- PyQt Signals & Slots
- PyQt - Signals and Slots
- PyQt - Support and Signals
- PyQt - Unbound and Bound Signals
- PyQt - New Signals with PyQtSignal
- PyQt - Connecting, Disconnecting, & Emitting Signals
- PyQt - Slot decorator
- PyQt - Slot Connection
- PyQt Layouts
- PyQt - Layout Management
- PyQt - QBoxLayout
- PyQt - QGridLayout
- PyQt - QFormLayout
- PyQt - QHBoxLayout
- PyQt - QVBoxLayout
- PyQt - QStackedLayout
- PyQt - QGraphicsGridLayout
- PyQt - QGraphicsAnchorLayout
- PyQt - QGraphicsLayout
- PyQt - QGraphicsLinearLayout
- PyQt Basic Widgets
- PyQt - Basic Widgets
- PyQt - Qlabel Widget
- PyQt - QLineEdit Widget
- PyQt - QPushButton Widget
- PyQt - QRadioButton Widget
- PyQt - QCheckBox Widget
- PyQt - QComboBox Widget
- PyQt - QSpinBox Widget
- PyQt - QMessageBox
- PyQt - QDialogButtonBox Widget
- PyQt - QFontComboBox Widget
- PyQt - QDoubleSpinBox Widget
- PyQt - QToolBox Widget
- PyQt - QMenuBar, QMenu & Qaction Widgets
- PyQt - QToolTip
- PyQt - QInputDialog Widget
- PyQt - QFontDialog Widget
- PyQt - QDialog Widget
- PyQt - QFileDialog Widget
- PyQt - QTab Widget
- PyQt - QSplitter Widget
- PyQt - QDock Widget
- PyQt - QStatusBar Widget
- PyQt - QTabBar
- PyQt - QList Widget
- PyQt - QScrollBar Widget
- PyQt - QProgressBar
- PyQt - QCalendar Widget
- PyQt - QMessageBox Widget
- PyQt - QPlainTextEdit
- PyQt - QDateEdit
- PyQt - QDateTimeEdit
- PyQt - QTimeEdit
- PyQt - QTextEdit
- PyQt - QTextBrowser
- PyQt - QScrollArea
- PyQt - Drag and Drop
- PyQt - Multiple Document Interface
- PyQt - QDialog Class
- PyQt Views
- PyQt - QColumnView
- PyQt - QTableView
- PyQt Drawing API
- PyQt - Drawing API
- PyQt - Drawing a Line
- PyQt - Drawing a Rectangle
- PyQt - Drawing a Triangle
- PyQt - Drawing a Circle
- PyQt - Drawing a Ellipse
- PyQt - Drawing a Polygon
- PyQt - Geometric Transformation
- PyQt - Drawing Effect
- PyQt Groups
- PyQt - QButtonGroup
- PyQt - QGroupBox
- PyQt Effects
- PyQt - Effects
- PyQt - Opacity Effect
- PyQt - QGraphicsBlur Effect
- PyQt - QGraphicsColorize Effect
- PyQt - QGraphicsDropShadow Effect
- PyQt Events
- PyQt - Event Handling
- PyQt - Drag & Drop Events
- PyQt - File Open Event
- PyQt - Action Event
- PyQt - Hide Event
- PyQt - Resize Event
- PyQt Database
- PyQt - Database Handling
- PyQt Essentials
- PyQt - BrushStyle Constants
- PyQt - QClipboard
- PyQt - QPixmap Class
- PyQt Useful Resources
- PyQt - Quick Guide
- PyQt - Useful Resources
- PyQt - Discussion
PyQt - QStatusBar Widget
The status bar is a section located at the bottom of a primary window that serves to provide information about the current state of the window, such as what is being viewed and how it is being viewed. Additionally, it may display information about background tasks, such as printing, scanning, and formatting, or other contextual information, such as selection and keyboard state.
Furthermore, the status bar shows updates on the page as it loads. Most browsers keep the status bar hidden and most of the time it will only appear when there is something to display.
QMainWindow object reserves a horizontal bar at the bottom as the status bar. It is used to display either permanent or contextual status information.
There are three types of status indicators −
- Temporary − It covered the horizontal status bar at the bottom of the window. This explains tool tip texts or menu entries.
- Normal − It occupies a portion of the status bar and is hidden from a temporary message. Thus, this is used to display the page and line number in a word processor.
- Permanent − The third and final type is 'Permanent' and this is never hidden. It is used for important mode indications such as some applications which put a Caps Lock indicator in the status bar.
Status bar of QMainWindow is retrieved by statusBar() function. status_Bar.method_name function activates it.
Note that, we can directly the method self.statusBar() to get the QStatusBar object and call the other methods such as addWidget(), addPermanentWidget() and showMessage().
self.statusBar = QStatusBar() self.status_Bar.method_name()
Methods of QStatusBar Class
Below are the list of methods with its descriptions in detail −
Sr.No. | Methods & Description |
---|---|
1 |
addWidget() Adds the given widget object in the status bar |
2 |
addPermanentWidget() Adds the given widget object in the status bar permanently |
3 |
showMessage() Displays a temporary message in the status bar for a specified time interval |
4 |
clearMessage() Removes any temporary message being shown |
5 |
removeWidget() Removes specified widget from the status bar. |
Example
In the following example, we illustrate the task for status bar i.e. present at the bottom of the window.
import sys from PyQt6.QtWidgets import (QApplication, QMainWindow, QLabel, QPushButton) from PyQt6.QtCore import Qt class MyWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("QStatusBar") self.setFixedSize(500, 300) # Create a status bar self.status_bar = self.statusBar() # Permanent label (Caps Lock indicator) self.caps_lock_label = QLabel("Caps Lock: OFF") self.status_bar.addPermanentWidget(self.caps_lock_label) # Normal label (Current Page) self.page_label = QLabel("Current Page: 1") self.status_bar.addWidget(self.page_label) # Button to create a temporary messages self.show_message_button = QPushButton("Show Temporary Message") self.show_message_button.clicked.connect(self.show_temporary_message) self.setCentralWidget(self.show_message_button) def show_temporary_message(self): self.status_bar.showMessage("This message disappears in 4 seconds", 4000) if __name__ == "__main__": app = QApplication(sys.argv) window = MyWindow() window.show() sys.exit(app.exec())
Output
The above code produces the following output −
