python - tkinter 顶级小部件有哪些协议(protocol)

标签 python tkinter protocols toplevel

当使用 Tk.protocol 参数时可能是 “WM_DELETE_WINDOW”、“WM_SAVE_YOURSELF”和“WM_TAKE_FOCUS”

但是还有其他的吗?

具体来说,在我的程序中,我想创建一个跟随另一个窗口的窗口

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”

我的实际问题是还有哪些其他协议(protocol)或者我在哪里可以找到它们

最佳答案

这是您正在寻找的答案:

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. Those are the only three defined by the ICCCM; the freedesktop.org [EWMH] spec also defines _NET_WM_PING.

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 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.)

来源:https://wiki.tcl.tk/8454

关于python - tkinter 顶级小部件有哪些协议(protocol),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50630793/

相关文章:

ios - 如何在 iOS 中同步两个异步委托(delegate)方法回调?

ios5 - 协议(protocol)中的方法未在 iOS 中实现

python - 为什么 pandas df.plot.bar() 不接受宽度数组?

python - 按位置删除文本 tkinter

python - _tkinter.TclError : no display name and no $DISPLAY environment variable for new OS X Mavericks

Python Tkinter 或 ttk,将文本发送到其他顶层窗口

python - Pandas 删除列多索引中的空白行

python - Keras - 如何预测两个值而不是一个值?

python - PyImport_Import 失败 - 返回 NULL

swift - 我如何在 swift 结构/类类型中支持这种初始化?