Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 $

like image 870
James the Great Avatar asked Sep 18 '26 10:09

James the Great


1 Answers

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()
like image 109
James the Great Avatar answered Sep 21 '26 00:09

James the Great



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!