我可以使用 Python 在 Windows 上创建类似面板的东西吗?
抱歉,标题含糊不清,无法提供更多信息%)
我想要的是屏幕顶部的 5px 水平面板,我可以在上面绘图(并且可能也可以处理点击)。
以下功能之一将非常棒(尽管我知道将它们结合起来可能不太可能):
- 面板应该就像 Windows 自己的任务栏一样,即最大化的窗口不应与其重叠,而是从其下方
- 开始面板也应该显示在全屏应用程序中
是否可以在Python中执行此操作?
谢谢。
Sorry for the vague title, couldn't come up with anything more informative %)
What I want is a 5px horizontal panel on the top of the screen that I can draw on (and, possible, handle clicks on too).
One of the following features would be awesome (although I understand it's probably not really possible to combine both of them):
- the panel should be just like the Windows's own taskbar, i.e., maximized windows should not overlap it, but start below it instead
- the panel should show in fullscreen apps too
Is it possible to do this in Python?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这是可能的。 “如何”部分取决于您选择的 GUI 库,有很多选项,但大多数人会推荐以下两个:wxPython 或 PySide(即 Qt for Python)。
PySide 有很好的文档和教程。
您需要做的是创建一个 QMainWindow 实例并根据您的要求设置 WindowFlags。您可能需要以下组合
Qt::Window | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint
。像这样的事情:
请注意,此类窗口的“保持在顶部”性质是有限的。有一些特定于 Win32 的方法可以对抗它并变得更高,但这样的要求将是一个设计错误。
Yes, it's possible. The "how" part depends on the GUI library you choose for which there are many options, but most people will recommend the following two: wxPython or PySide which is Qt for Python.
PySide has good documentation and tutorials.
What you will want to do is create a QMainWindow instance and set the WindowFlags to your requirements. You probably want the following combination
Qt::Window | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint
.Something like this:
Note, that there is a limit to the "staying on top" nature of such windows. There are Win32-specific ways to fight it and get even higher, but such requirement would be a design error.