PyQt5 – Set status bar message in window
Last Updated :
26 Mar, 2020
In this article, we will see how to set message to status bar of window. A status bar is a graphical control element which poses an information area typically found at the window’s bottom. It can be divided into sections to group information. Its job is primarily to display information about the current state of its window.
In order to do this we will use showMessage()
method.
Syntax : self.statusBar().showMessage(message)
Argument : It takes string as argument.
Action performed : It sets the message to status bar.
Code :
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys
class Window(QMainWindow):
def __init__( self ):
super ().__init__()
self .setWindowTitle( "Python" )
self .setGeometry( 60 , 60 , 600 , 400 )
self .statusBar().showMessage( "this is status bar" )
self .label_1 = QLabel( "Status Bar" , self )
self .label_1.move( 100 , 100 )
self .label_1.setStyleSheet( "border :5px solid blue;" )
self .label_1.resize( 80 , 100 )
self .show()
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :
Share your thoughts in the comments
Please Login to comment...