如何使Tkinter窗口跳到前面? [英] How to make a Tkinter window jump to the front?

查看:1364
本文介绍了如何使Tkinter窗口跳到前面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让Tkinter应用程序跳到前台?目前,窗口出现在所有其他窗口后面,并没有得到重点。



是否有一些方法可以调用?

解决方案

当你说我的其他窗口时,你的意思是你的应用程序窗口,你可以在Toplevel或Tk上使用 lift()方法:

  root.lift()

您希望窗口保持在所有其他窗口之上,使用:

$ $ $ $ $ $ c $ root.attributes( - topmost,True)

其中是您的Toplevel或Tk。不要忘记最顶层的 -

为了使其成为临时,请禁用最上面的权限:

  def raise_above_all(window): 
window.attributes(' - topmost',1)
window.attributes(' - topmost',0)

只要传入你想要提出的参数,就可以了。


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?

解决方案

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)

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆