https://github.com/gvozdevleonid/backdrop-in-pyqt-pyside
BackDrop effect in PyQt/PySide
https://github.com/gvozdevleonid/backdrop-in-pyqt-pyside
glassmorphism pyqt pyside python
Last synced: about 1 year ago
JSON representation
BackDrop effect in PyQt/PySide
- Host: GitHub
- URL: https://github.com/gvozdevleonid/backdrop-in-pyqt-pyside
- Owner: GvozdevLeonid
- License: mit
- Created: 2022-12-28T12:48:12.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-21T15:14:33.000Z (over 2 years ago)
- Last Synced: 2025-03-31T05:41:31.549Z (about 1 year ago)
- Topics: glassmorphism, pyqt, pyside, python
- Language: Python
- Homepage:
- Size: 8.73 MB
- Stars: 14
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BackDrop effect in PySide6
So far this is working on Pyside6 and possibly PySide2 as well. Does not work on PyQt6, I will fix the error in the future
This repository contains two classes: BackDrop is a graphical effect in which you need to set a list of backgrounds, blur and a border radius. BackDropWrapper - a handy wrapper for displaying and animation the backdrop effect.
BackDrop(blur: int = 0, radius: int = 0, backgrounds: list[dict] = None)
BackDropWrapper(widget: QtWidgets.QObject , blur: int = 0, radius: int = 0, backgrounds: list[dict] = None, shine_animation: list = None, move_animation: tuple = None)
The backgrounds is set as follows:
grad = QtGui.QLinearGradient(0, 0, 1, 1)
grad.setCoordinateMode(QtGui.QLinearGradient.CoordinateMode.ObjectMode)
grad.setStops([(0, QtGui.QColor(255, 255, 255, 255)), (0.35, QtGui.QColor(255, 255, 255, 125)), (0.65, QtGui.QColor(255, 255, 255, 125)), (1,QtGui.QColor(255, 255, 255, 255))])
backgrounds=[{"background-color": grad, "border": QtGui.QColor("#FFFFFF"),"border-width": 2, "opacity": .4}]
Animations run when you hover over the widget and also run in reverse again when you leave the mouse.
All animations are disabled by default, but you can enable them by passing the following arguments:
shine_animation = (duration: int, forward: bool, angle: int, width: int, color: QtGui.QColor)
move_animation = (duration: int, offset: tuple, forward: bool)
or you can create BackDropWrapper element and set:
bdw = BackDropWrapper(QtWidgets.QLabel("Hello World!"), blur=10, radius=25, backgrounds=backgrounds)
bdw.enable_shine_animation(color=QtGui.QColor(255, 255, 255, 90))
bdw.enable_move_animation(offset=(0, -30))
# Example file preview

