Python Tkinter:移除窗口边框

3
如何在不使用overrideredirect的情况下去除TopLevel的边框?
TopLevel.overrideredirect(True)

提供一份示例代码将是很棒的。

Python 2.7.3,Linux,Tkinter版本 $Revision:81008 $


你对overrideredirect有什么问题?它存在的原因正是你所要求的——去除窗口管理器边框。 - Bryan Oakley
我制作了一个进度条,并使用overrideredirect隐藏了边框。然而,当我使用TopLevel.transient(parentWindow)时,它不起作用。我使用transient的原因是希望在父窗口最小化时也最小化进度条。但是,如果将overrideredirect设置为True,则使用TopLevel.transient(parentWindow)不会产生任何效果。 - James the Great
你能否使用Linux等效于Windows WinAPI的接口? - Fenikso
我只能在Linux上运行我的代码,如果这是你的意思 :) - James the Great
我的意思是我不知道如何在Tk中直接完成它,但是我可以使用窗口句柄和WinAPI调用来完成它,只需4行代码,没有任何副作用。在Linux中应该有类似的东西。 - Fenikso
希望吧。现在我还一无所知,我的程序看起来也不好。 - James the Great
1个回答

2
在Bryan Oakley的帮助下,我找到了一个解决方案,可以在解决我的问题时使用“overrideredirect”,即使用“Unmap”事件。
以下示例代码显示,当使用“Map”和“Unmap”时,附加窗口可以与主窗口一起最小化:
import Tkinter
class App:
    def __init__(self):
        self.root = Tkinter.Tk()
        Tkinter.Label(self.root, text="main window").pack()
        self.window = Tkinter.Toplevel()
        self.window.overrideredirect(True)
        Tkinter.Label(self.window, text="Additional window").pack()
        self.root.bind("<Unmap>", self.OnUnMap)
        self.root.bind("<Map>", self.OnMap)
        self.root.mainloop()
    def OnMap(self, e):
        self.window.wm_deiconify()
    def OnUnMap(self, e):
        self.window.wm_withdraw()
app=App()

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接