Open In App

PyQt5 – Set skin to Status Bar

Last Updated : 26 Mar, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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__()
  
        # 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  skin to status bar
        self.statusBar().setStyleSheet("border-image : url(skin.png);")
  
        # 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()
  
  
# start the app
sys.exit(App.exec())


Output :



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads