Open In App

PyQt5 Label – Setting offset to the shadow

Last Updated : 10 May, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

In this article we will see how we can set offset to shadow of the label, offset is basically distance between the shadow of the label and the label by default offset value is 8 although we can change it any time.

In order to do this we use setOffset method

Syntax : shadow.setOffset(n)
Here shadow is the QGraphicsDropShadowEffect object

Argument : It takes QPointF object as argument

Return : None

Below is the implementation




# importing libraries
from PyQt5.QtWidgets import * 
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import * 
from PyQt5.QtCore import *
import sys
  
  
class Window(QMainWindow):
  
    def __init__(self):
        super().__init__()
  
        # setting background color of window
        # self.setStyleSheet("background-color : black;")
  
        # setting title
        self.setWindowTitle("Python ")
  
        # setting geometry
        self.setGeometry(100, 100, 600, 400)
  
        # calling method
        self.UiComponents()
  
        # showing all the widgets
        self.show()
  
    # method for widgets
    def UiComponents(self):
  
        # creating label
        label = QLabel("Label", self)
  
        # setting alignment
        label.setAlignment(Qt.AlignCenter)
  
        # setting geometry to the label
        label.setGeometry(200, 100, 150, 60)
  
        # setting border
        label.setStyleSheet("border : 8px solid black")
  
        # creating a QGraphicsDropShadowEffect object
        shadow = QGraphicsDropShadowEffect()
  
        # setting blur radius
        shadow.setBlurRadius(20)
  
        # setting offset
        shadow.setOffset(100)
  
        # adding shadow to the label
        label.setGraphicsEffect(shadow)
  
          
# create pyqt5 app
App = QApplication(sys.argv)
  
# create the instance of our Window
window = Window()
  
# start the app
sys.exit(App.exec())


Output :



Similar Reads

PyQt5 Label - Setting horizontal offset of shadow
In this article we will see how we can set the horizontal offset of shadow to the label, offset is basically distance between the shadow of the label and the label by default offset value is 8 although we can change it any time. In order to do this we use setXOffset method Syntax : shadow.setXOffset(n) Here shadow is the QGraphicsDropShadowEffect o
2 min read
PyQt5 Label - Setting Vertical offset of shadow
In this article we will see how we can set the vertical offset of shadow to the label, offset is basically distance between the shadow of the label and the label by default offset value is 8 although we can change it any time. In order to do this we use setYOffset method Syntax : shadow.setYOffset(n) Here shadow is the QGraphicsDropShadowEffect obj
2 min read
PyQt5 Label - Accessing offset of the shadow
In this article we will see how we can access the offset of shadow of the label, offset is basically distance between the shadow of the label and the label by default offset value is 8 although we can change it any time with the help of setOffset method. In order to do this we use offset method Syntax : shadow.offset() Here shadow is the QGraphicsD
2 min read
PyQt5 Label - Accessing Vertical offset of shadow
In this article we will see how we can access the vertical offset of shadow to the label, offset is basically distance between the shadow of the label and the label by default offset value is 8 although we can change it any time. In order to do this we use yOffset method Syntax : shadow.yOffset() Here shadow is the QGraphicsDropShadowEffect object
2 min read
PyQt5 Label - Accessing Horizontal offset of shadow
In this article we will see how we can access the horizontal offset of shadow to the label, offset is basically distance between the shadow of the label and the label by default offset value is 8 although we can change it any time. In order to do this we use xOffset method Syntax : shadow.xOffset() Here shadow is the QGraphicsDropShadowEffect objec
2 min read
PyQt5 Label - Setting blur radius to shadow
In this article we will see how we can set blur radius to the shadow of the label. The blur radius, if set to 0 the shadow will be sharp, the higher the number, the more blurred it will be, by default the blur radius is 0. In order to set blur radius to the shadow of label with the help of setBlurRadius method Syntax : shadow.setBlurRadius(n) Here
2 min read
PyQt5 Label - Setting color to shadow
In this article we will see how we can set shadow color to the label, when we create a shadow to the label it is by default of black color although we can its color. In order to set color to the shadow of label with the help of setColor method Syntax : shadow.setColor(color_object) Here shadow is the QGraphicsDropShadowEffect object Argument : It t
2 min read
PyQt5 Scrollable Label - Setting tool tip to the label part
In this article we will see how we can set tool tip to the label part of scroll label, when know we can make scrollable label with the help of inheriting a scroll class and making label in it, but when we set tool tip to the class object tool tip is set to the whole widget i.e label and the scroll bar as well. In order to add tool tip the label par
3 min read
PyQt5 Scrollable Label – Setting tool tip duration to label part
In this article we will see how we can set tooltip duration to the label part of scroll label, when know we can make scrollable label with the help of inheriting a scroll class and making label in it, but when we set tooltip to the class object tooltip is set to the whole widget i.e label and the scroll bar as well. In order to add tooltip and its
3 min read
PyQt5 Label – Make shadow disappear according to user
In this article we will see how we can make the shadow disappear off the label according to the user. Shadow will be shown and disappear when user make the radio button checked and will appear when radio button is unchecked. In order to do this we use setEnabled method Syntax : shadow.setEnabled(bool) Argument : It takes bool as argument Return : N
2 min read
Practice Tags :