PyQt5 – Set skin to Status Bar
Last Updated :
26 Mar, 2020
Unlike setting background images, skins adjust themselves according to the size of status bar. In background image if the image size is large and status bar size is small only that part of image is displayable that comprises the size of status bar. The main reason of setting skin to status bar is that, status bar height is comparatively smaller than the normal images that’s why instead of using background images skin is preferable.
Background and skin will look like this:
Syntax : self.statusBar().setStyleSheet(“border-image : url(skin.png);”)
Argument : It takes string as argument.
Action performed : It sets skin 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 .statusBar().setStyleSheet( "border-image : url(skin.png);" )
self .label_1 = QLabel( "status bar" , self )
self .label_1.move( 100 , 100 )
self .label_1.setStyleSheet( "border :1px solid blue;" )
self .label_1.adjustSize()
self .show()
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...