withdraw
和wm_withdraw
有什么区别?
import time
import tkinter as tk
def hide():
root.withdraw()
time.sleep(2)
root.deiconify()
root = tk.Tk()
tk.Button(root, text = 'hide', command = hide).pack()
root.mainloop()
单击“隐藏”按钮时,窗口被隐藏。它从面板(任务栏)消失,并且在任务视图(所有打开的窗口的同时视图)中2秒钟不可见。
import time
import tkinter as tk
def hide():
root.wm_withdraw()
time.sleep(2)
root.deiconify()
root = tk.Tk()
tk.Button(root, text = 'hide', command = hide).pack()
root.mainloop()
相同的代码,但用wm_withdraw
代替withdraw
。再次,单击“隐藏”按钮使任务栏条目和窗口本身都不可见2秒钟。
这两个之间有什么区别吗?我应该使用哪一个?此外,我应该使用deiconify
还是wm_deiconify
?所有四个组合(withdraw
,deiconify
,wm_withdraw
,deiconify
,withdraw
,wm_deiconify
,wm_withdraw
,{{1} })似乎做的完全一样。是否有任何应用程序可以执行不同的操作?
答案 0 :(得分:1)
答案 1 :(得分:1)
withdraw和wm_withdraw之间没有区别。我无法指定执行此操作的原因,但是这是tkinter的来源,我们在其中包含行withdraw = wm_withdraw
(这很清楚两个调用都以相同的方法结束):
def wm_withdraw(self):
"""Withdraw this widget from the screen such that it is unmapped
and forgotten by the window manager. Re-draw it with wm_deiconify."""
return self.tk.call('wm', 'withdraw', self._w)
withdraw = wm_withdraw