简体   繁体   English

使Tkinter窗口不总是在顶部

[英]Make Tkinter window not always on top

I have a simple program as follows: 我有一个简单的程序如下:

from Tkinter import *

class Run:
    def __init__(self,parent):
        parent.overrideredirect(True)

root = Tk()
app = Run(root)
root.mainloop()

When I run this program, the undecorated root window always stays on top. 当我运行此程序时,未修饰的根窗口始终保持在顶部。 How can I make it so any other window can be on top of it, whilst having no decorations? 我怎么能这样做,所以任何其他窗口都可以在它上面,而没有装饰?

I have tried setting 'topmost' to 'False' as well, but to no avail. 我也试过将'topmost'设置为'False',但无济于事。

I am running Ubuntu 13.04. 我正在运行Ubuntu 13.04。

Thanks in advance 提前致谢

This code below, will put your window on the background on every 100ms , no matter what, so everything will be in the front of it all the time. 下面这段代码,无论如何,每隔100ms就会把你的窗口放在背景上,所以一切都会在它的前面。 I think this is what you were asking for: 我认为这就是你要求的:

from tkinter import *

class Run:
    def __init__(self):
        self.root = Tk()
        self.root.overrideredirect(True)
    def put_back(self):
        # this method will put the window to the background
        self.root.lower()
        # recursive calling of put_back method
        self.root.after(100, self.put_back)

app = Run()
# Start the recursion
app.put_back()
app.root.mainloop()

如果我单击一个不同的窗口,这似乎会自动发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM