PyQt5 – StatusBar的clearMessage()
PyQt5支持一个窗口状态栏。clearMessage()方法用于清除状态栏上由showmessage()方法设置的信息。
语法: self.statusBar().clearMessage()
参数: 它不需要参数。
执行的操作: 它清除了状态栏中的信息。
代码。
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys
class Window(QMainWindow):
def __init__(self):
super().__init__()
# set the title
self.setWindowTitle("Python")
# setting the geometry of window
self.setGeometry(60, 60, 600, 400)
# setting status bar message
self.statusBar().showMessage("this is status bar")
# clearing the status bar message
self.statusBar().clearMessage()
# creating a label widget
self.label_1 = QLabel("No message in status bar", self)
# moving position
self.label_1.move(100, 100)
# setting up the border
self.label_1.setStyleSheet("border :1px solid blue;")
# resizing label
self.label_1.adjustSize()
# show all the widgets
self.show()
# create pyqt5 app
App = QApplication(sys.argv)
# create the instance of our Window
window = Window()
# start the app
sys.exit(App.exec())
输出 :