【发布时间】:2018-05-31 18:40:58
【问题描述】:
当使用 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”
我的实际问题还有哪些其他协议,或者我在哪里可以找到它们
【问题讨论】:
-
您想要的是绑定而不是协议。您可以使用
<Configure>事件来跟踪窗口并跟随另一个窗口。这需要一些跟踪,但设置起来应该足够简单。
标签: python tkinter protocols toplevel