[Python combat basics] How to create a status bar in PyQt6

Table of contents

1. The actual combat scene

2. Main points of knowledge

file read and write

Basic grammar

PyQt6

sys

Three, rookie combat


1. The actual combat scene

Actual combat scenario: how to create a status bar in PyQt6

2. Main points of knowledge

  • file read and write

  • Basic grammar

  • PyQt6

  • sys

Three, rookie combat

The status bar is a widget that displays status information.

import sys
from PyQt6.QtWidgets import QMainWindow, QApplication


class Example(QMainWindow):

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

        self.initUI()


    def initUI(self):

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

        self.setGeometry(300, 300, 350, 250)
        self.setWindowTitle('Statusbar')
        self.show()


def main():

    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec())


if __name__ == '__main__':
    main()

QMainWindow Create a status bar using 

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

Use  QtGui.QMainWindow the method to create the status bar, which creates a status bar and returns the statusbar object, and then calls  showMessage the method to display a message on the status bar.


Rookie combat, keep learning!  

Guess you like

Origin blog.csdn.net/qq_39816613/article/details/126891382