Python overlay window [closed]

限于喜欢 提交于 2019-12-25 01:15:29

问题



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:


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.



来源:https://stackoverflow.com/questions/11836912/python-overlay-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!