5

I am using Python 3.9.1 and PyQt6. Now I want to create a window with blurred background, which should look something like below:

Blurred Window Background Demo

It would be helpful if anybody provide me a code for this.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • Please take your time to read [how to ask](https://stackoverflow.com/help/how-to-ask) good questions and [how to check them](https://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist), and consider that on StackOverflow users really don't ask "can anybody tell me how can I do xyz". If you have got some code that doesn't work as expected, then you can provide a [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) and we'll be glad to help, otherwise such questions don't get generally answered. – musicamante Mar 28 '21 at 15:24
  • Besides that, in this specific case, you cannot do this directly with PyQt, and you need to use the platform's api instead (assuming they allow you to do that). – musicamante Mar 28 '21 at 15:25

2 Answers2

6

the real deal:

python -m pip install BlurWindow

import sys
from PySide2.QtWidgets import *
from PySide2.QtCore import *

from BlurWindow.blurWindow import blur



class MainWindow(QWidget):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.resize(500, 400)

        blur(self.winId())

        self.setStyleSheet("background-color: rgba(0, 0, 0, 0)")



if __name__ == '__main__':
    app = QApplication(sys.argv)
    mw = MainWindow()
    mw.show()
    sys.exit(app.exec_())

win11

Pedro
  • 360
  • 3
  • 13
0

Well taken from KDE Plasma, its easy now to do this with Python.

For details, check this out - Watch this carefully

You will need to use the library provided called fluentapp -

For Project made with python - size 95 mb

You will need to extract it from the project and use the reference guide provided. I have already tried it its cool and enhances the beauty of your app.

Syntax is easy e.g. -

import fluentapp.pyqt6.windowtools as wingui

wingui.setWindowAlpha("0.5") # Make window transparent

wingui.addGaussianBlur(radius=20, cover= False) 

#if you want to use additional layer for dark and light theme, you can set cover True for dark.
 
     Your Code Here ---- 
Lalji Dhameliya
  • 1,729
  • 1
  • 17
  • 26