Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

PyQt5 – How to add Separator in Status Bar ?

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

In this article we will see how to add separator in status bar. separator are basically just vertical lines which are used to distinguish items.

Below is the difference between the statusbar with separator and without separator.

The main concept is that we will add a widget between two labels which will be a vertical line which will act as a separator.

Code :




from PyQt5.QtCore import * 
from PyQt5.QtGui import * 
from PyQt5.QtWidgets import * 
import sys
  
# creating VLine class
class VLine(QFrame):
  
    # a simple Vertical line
    def __init__(self):
  
        super(VLine, self).__init__()
        self.setFrameShape(self.VLine|self.Sunken)
  
  
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 and padding with different sizes
        self.statusBar().setStyleSheet("border :3px solid black;")
  
        # creating a label widget
        self.label_1 = QLabel("Label 1")
  
        # setting up the border
        self.label_1.setStyleSheet("border :2px solid blue;")
  
        # creating a label widget
        self.label_2 = QLabel("Label 2")
  
        # setting up the border
        self.label_2.setStyleSheet("border :2px solid blue;")
  
        # adding label to status bar
        self.statusBar().addPermanentWidget(self.label_1)
  
        # adding VLine object
        self.statusBar().addPermanentWidget(VLine())
  
        # adding label
        self.statusBar().addPermanentWidget(self.label_2)
        # 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 :


My Personal Notes arrow_drop_up
Last Updated : 22 Apr, 2020
Like Article
Save Article
Similar Reads
Related Tutorials