效果如下图:
代码:
1 """ 2 ZetCode PyQt5 tutorial 3 This program creates a statusbar. 4 """ 5 import sys 6 from PyQt5.QtWidgets import QMainWindow, QApplication 7 # The statusbar is created with the help of the QMainWindow widget. 8 9 10 class Example(QMainWindow): 11 12 def __init__(self): 13 super().__init__() 14 15 self.initUI() 16 17 18 def initUI(self): 19 20 # The showMessage() displays a message on the statusbar. 21 self.statusBar().showMessage('Ready') 22 23 self.setGeometry(300, 300, 250, 150) 24 self.setWindowTitle('Statusbar') 25 self.show() 26 27 28 if __name__ == '__main__': 29 30 app = QApplication(sys.argv) 31 ex = Example() 32 sys.exit(app.exec_())