Skip to content
Related Articles
Open in App
Not now

Related Articles

PyQt5 – Set skin to Status Bar

Improve Article
Save Article
Like Article
  • Last Updated : 26 Mar, 2020
Improve Article
Save Article
Like Article

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):
        # set the title
        # 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
        # show all the widgets
# create pyqt5 app
App = QApplication(sys.argv)
# create the instance of our Window
window = Window()
# start the app

Output :

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!