Create a Transparent Blur Window
Asked Answered
S

2

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.

Skellum answered 28/3, 2021 at 15:20 Comment(2)
Please take your time to read how to ask good questions and how to check them, 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 and we'll be glad to help, otherwise such questions don't get generally answered.Pampa
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).Pampa
H
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

Haymow answered 12/7, 2021 at 4:7 Comment(0)
F
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 ---- 
Forme answered 27/4, 2021 at 11:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.