Python覆盖窗口 [英] Python overlay window

查看:267
本文介绍了Python覆盖窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在Python程序中,我想在鼠标指针下方绘制一个(可能是形状的)覆盖窗口,该窗口应该紧随其后(我已经有了在mousemove上获取其新坐标的代码),并且不得干扰对其他窗口的点击.我的目标平台是Linux(KDE),但是如果它是跨平台的,那就更好了.我该怎么做,例如使用Tkinter或PyQT?
预先感谢您的回答
我忘了说窗口应该支持透明性(它将是鼠标指针周围的alpha混合圆)


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
I forgot to say that the window should support transparency (it will be an alpha blended circle around the mouse pointer)

推荐答案

在PyQt中,您可以创建任何显示为窗口的QWidget,并使用QWidget.setGeometry()设置其在屏幕上的位置.

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

您可以阅读有关背景透明性的文档: http://qt-project.org/doc/qt- 4.8/qwidget.html#autoFillBackground-prop

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?

但是,为了避免引起鼠标单击,可能会很困难. 最简单的解决方案可能是使用QWidget.setMask或Qt :: WA_TransparentForMouseEvents(请参见上面的第一个链接),但是我认为这在某种程度上取决于操作系统的窗口管理器,而不受程序的控制.一种可能的解决方法可能是将您的界面分解为围绕光标平铺的单独窗口.

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.

这篇关于Python覆盖窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆