如何使用 python-xlib 管理我的应用程序窗口?
我想找到一种 Linux 范围内(只要它使用 X11)的方法来控制我的应用程序的窗口几何形状,我使用 Python 对其进行编程。我所有的研究都指向使用 python-xlib,但它的文档记录却很少。
我想要实现的是:
- 定义窗口在屏幕上的位置
- 定义最小和最大尺寸
- 启用/禁用窗口调整大小
- 为窗口保留屏幕空间 保留
- 窗口上方/下方
- 跳过或不跳过任务栏(又名窗口列表)
- 设置窗口装饰/ undecorated
- 设置窗口标志(正常、弹出、对话、启动、停靠、忽略)
注意:我不想使用 Xlib 创建,而是想告诉 X 如何处理我创建的窗口与一些 GUI 库(PyQt for实例)。
我怎样才能做到这一点?我意识到这个问题相当大:你至少有关于我如何抓住我的窗户的提示吗?我可以在模块中的哪里找到答案?
编辑: nm的答案提供了很好的资源,还有Unix StackExchange 上的另一个问答,它提供了一个很好的示例,说明如何控制 X 显示的应用程序窗口。
I would like to find a linux-wide (insofar as it uses X11) way to control the window geometry of my application, which I program using Python. All my researches point to using python-xlib, which happens to be very poorly documented.
What I'd like to achieve is:
- define position of window on screen
- define minimum and maximum size
- enable / disable window resizing
- reserve screen-space for window
- keep window above/below
- skip or not task-bar (aka window list)
- set window decorated / undecorated
- set window flags (normal, pop-up, dialogue, splash, dock, ignored)
NB: I don't want to create the with Xlib, instead I want to tell X what to do with the window i created with some GUI library (PyQt for instance).
How can I go about doing this? I realise this question is quite a big one: do you have hints at least as to how I can get hold of my window? Where in the module can I find my answers?
Edit: n.m.'s answer offered great resources, and there is also another Q&A on Unix StackExchange that provides a great example on how to get control on an application window displayed by X.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要知道的第一个关键字是 ICCCM。您需要熟悉 ICCCM 手册(请参阅 http://tronche.com/gui/x/icccm /)和 FreeDesktop 扩展相同(请参阅 http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html)。至于你的问题
我不太明白。您调用
create_window
,该函数将返回您的 Window 对象。或者你还有别的意思吗?The first keyword you need to know is ICCCM. You need to be familiar with the ICCCM manual (see http://tronche.com/gui/x/icccm/) and the FreeDesktop extensions to the same (see http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html). As for your question
I don't quite understand it. You call
create_window
and the function returns your Window object. Or do you mean something else?昨天才发现这一点,我认为与使用各种
xdotool
、wmctrl
、gtk
和tkinter
相比,它非常棒移动窗口:请注意,如果您使用
wmctrl
来获取窗口 ID,则需要在调用x11_move_window
之前将其从十六进制转换为十进制:Just discovered this yesterday and I think it's awesome compared to using variety of
xdotool
,wmctrl
,gtk
andtkinter
to move windows around:Note if you used
wmctrl
to get your window ID you need to convert it from hexadecimal to decimal before callingx11_move_window
: