PyQt5 - 状态栏的可见性状态
状态栏的可见性状态可以称为如果可见则返回True,否则返回False。我们可以使用isVisible
方法检查它。
Syntax : class_object.status_bar_object.isVisible()
Argument : It takes no parameter.
Return : It return bool.
注意#1:如果我们不创建状态栏对象,此属性将为假。
注意 #2:如果在构造函数中调用此方法,它将始终返回 False,就像之前显示任何可见状态都是 False 一样。
代码 :
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")
# setting border
self.statusBar().setStyleSheet("border :3px solid black;")
# setting tool tip for status bar
self.statusBar().setToolTip("Hello ! from status bar")
# creating a label widget
self.label_1 = QLabel("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()
# getting visibility status
t = window.statusBar().isVisible()
# printing value of t
print(t)
# start the app
sys.exit(App.exec())
输出 :
True