PySide2 (Qt with Python) doesn't detect compositing (X11 and Compton) - No transparency
-
My script uses PySide2 to use Qt in Python. The script requires transparency (can see desktop behind window).
I use Ubuntu with X11, LXQT and Compton. Also tested with LXDE and XFCE without success. Transparency works for regular windows like browser and text editor, but not for my python script.
Transparency is set via
background: url(bg_with_transparency.png)
but I also tested with rgba color andw.setWindowOpacity(0.5)
without success.Following flags are set: (Window must also be click-through)
w.setWindowFlags(w.windowFlags() | QtCore.Qt.WindowTransparentForInput | QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint) w.setAttribute(QtCore.Qt.WA_TranslucentBackground) w.setAttribute(QtCore.Qt.WA_NoSystemBackground)
Without
WA_TranslucentBackground
andWA_NoSystemBackground
the image displays with a black background instead of transparency. When I enabled these flags without compositing, the window displayed pure black. After I enable Compton, the window does not display at all (no error) andQtX11Extras.QX11Info.isCompositingManagerRunning()
returns false.How to fix this? I prefer to use PySide2 and Python but I am open to other GUIs or programming languages, as long as the script works with Ubuntu and has following features:
- Transparency (background is PNG with rgba)
- Click through capability
- Always on top
Thanks.
-
Hi and welcome to devnet,
Did you also try that with PyQt5 ?