Python overlay window [closed]

2019-08-17 18:18发布


In a Python program I want to draw a (possibly shaped) overlay window under the mouse pointer, that should follow it (I already have the code to get its new coordinates on mousemove) and must not interfere with clicks to other windows. My target platform is Linux (KDE) but if it's cross platform it's better. How can I do it, for example with Tkinter or PyQT?
Thanks in advance for the answers
EDIT: I forgot to say that the window should support transparency (it will be an alpha blended circle around the mouse pointer)

1条回答
老娘就宠你
2楼-- · 2019-08-17 18:34

In PyQt, you can create any QWidget to show as a window and use QWidget.setGeometry() to set its position on screen.

You can read the documentation on background transparency: http://qt-project.org/doc/qt-4.8/qwidget.html#autoFillBackground-prop

..and this question to get rid of the window borders: How to remove the window border (containing minimize, maximize and close buttons) from a Qt widget?

To avoid catching mouse clicks, though, could be difficult. The simplest solution might be to use QWidget.setMask or perhaps Qt::WA_TransparentForMouseEvents (see first link above), but I'm betting at some level this is up to the OS's window manager and out of the control of your program. One possible workaround might be to break up your interface into separate windows that are tiled around the cursor.

查看更多
登录 后发表回答