如何让 Tkinter 窗口跳到前面? [英] How to make a Tkinter window jump to the front?
问题描述
如何让 Tkinter 应用程序跳转到前面?目前,该窗口出现在我所有其他窗口的后面并且没有获得焦点.
How do I get a Tkinter application to jump to the front? Currently, the window appears behind all my other windows and doesn't get focus.
有什么我应该调用的方法吗?
Is there some method I should be calling?
推荐答案
假设您说我的其他窗口"时指的是您的应用程序窗口,那么您可以在 Toplevel 上使用 lift()
方法或传统知识:
Assuming you mean your application windows when you say "my other windows", you can use the lift()
method on a Toplevel or Tk:
root.lift()
如果您希望窗口位于所有其他窗口之上,请使用:
If you want the window to stay above all other windows, use:
root.attributes("-topmost", True)
其中 root
是您的 Toplevel 或 Tk.不要忘记"topmost"
前面的-
!
Where root
is your Toplevel or Tk. Don't forget the -
infront of "topmost"
!
要使其成为临时,请在之后立即禁用最上面:
To make it temporary, disable topmost right after:
def raise_above_all(window):
window.attributes('-topmost', 1)
window.attributes('-topmost', 0)
只需传入您想要作为参数引发的窗口,这应该可以工作.
Just pass in the window you want to raise as a argument, and this should work.
这篇关于如何让 Tkinter 窗口跳到前面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!