James the Great
James the Great

Reputation: 951

Python Tkinter: Remove window border

How do you remove the border of a TopLevel without using overrideredirect?

TopLevel.overrideredirect(True)

It would be great if a sample code can be provided.

Python 2.7.3, Linux, Tkinter version $Revision: 81008 $

Upvotes: 3

Views: 5843

Answers (1)

James the Great
James the Great

Reputation: 951

With the help of Bryan Oakley, I have realized a solution that would allow me to use 'overrideredirect' while solving my problem, and that is using 'Unmap' event.

The following example code shows that when the additional window can be minimized with the main window when using 'Map' and '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()

Upvotes: 2

Related Questions