有哪些 tkinter 顶级小部件的协议 [英] What protocols of tkinter toplevel widget are there
问题描述
当使用 Tk.protocol 参数可能是WM_DELETE_WINDOW"、WM_SAVE_YOURSELF"和WM_TAKE_FOCUS"
When using Tk.protocol arguments could be "WM_DELETE_WINDOW", "WM_SAVE_YOURSELF" and "WM_TAKE_FOCUS"
但是还有别的吗?
具体来说,在我的程序中,我想创建一个跟随另一个窗口的窗口
Concretely, in my program, I want to create a window that follows another window
root = Tk()
root.config(width = 100, height = 100
a = Tk()
a.overredirect()
#here I just make window stand below bottom left corner of original window
#I succeded in doing that, but it is not ellegant at all and partially functional
#does anybody knows how to do it better
#note: this is not the main problem
a.geometry('%ix40+%s+%s' % (180,
int(g[g.index('+')+1:g.rindex('+')]) + 8,
int(g[g.rindex('+')+1:]) + 51 +
int(g[g.index('x')+1:g.index('+')])))
如果root在屏幕上移动,我应该让a"跟随root"
and here I should make "a" follow "root" if root moves on the screen
我的实际问题是还有哪些其他协议或在哪里可以找到所有协议
My actual question what other protocols are there or where can I find them all
推荐答案
这里是您正在寻找的答案:
Here is the answer you are looking for :
问.有没有办法获得 wm 的可用协议列表协议?手册页只列出了明显的/常见的(WM_DELETE_WINDOW、WM_SAVE_YOURSELF 和 WM_TAKE_FOCUS).
Q. Is there a way of getting a list of available protocols for wm protocol? The man pages only list the obvious / common ones (WM_DELETE_WINDOW, WM_SAVE_YOURSELF, and WM_TAKE_FOCUS).
A.这些是 ICCCM 定义的仅有的三个;freedesktop.org[EWMH] 规范还定义了 _NET_WM_PING.
A. Those are the only three defined by the ICCCM; the freedesktop.org [EWMH] spec also defines _NET_WM_PING.
注意 WM_SAVE_YOURSELF 已弃用,Tk 应用无法实现WM_TAKE_FOCUS 或 _NET_WM_PING 正确,所以 WM_DELETE_WINDOW 是只有一个应该使用.
Note that WM_SAVE_YOURSELF is deprecated, and Tk apps can't implement WM_TAKE_FOCUS or _NET_WM_PING correctly, so WM_DELETE_WINDOW is the only one that should be used.
DKF:Tk 现在以正确的方式为您自己处理 _NET_WM_PING;你永远不会在脚本级别看到这个.(本次活动的目的协议是让其他客户端——尤其是窗口管理器或会话管理器——确定应用程序是否是处理事件.这使它的实现正确地埋在Tk 的胆量.)
DKF: Tk now handles _NET_WM_PING for you by itself in the correct way; you'll never see this one at the script level. (The purpose of the protocol is to let other clients — especially a window manager or session manager — determine positively whether the application is processing events. That puts its implementation correctly buried in the guts of Tk.)
这篇关于有哪些 tkinter 顶级小部件的协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!