I have a top-level window, whose specific location is set via geometry string. w.overrideredirect(True)
is called because the top-level window mustn't have any window manager decorations. The official documentation states:
Be sure to call the .update_idletasks() method (see Section 26, “Universal widget methods”(p. 97)) before setting this flag.
So that's exactly what I did, but now window manager decorations appear. It works fine if I don't call w.update_idletasks()
.
Code:
w = tk.Toplevel(self.parent_frame)
w.geometry('48x240 1567 209')
w.update_idletasks()
w.overrideredirect(True)
I'm using Python 3.8.10 with Tk version 8.6.10 on Ubuntu 20.04.3 LTS.
CodePudding user response:
That's not official documentation, and it is wrong. The exact opposite is true: you must set the flag before tkinter has the chance to draw the window on the screen. That means before mainloop
is started, and before any calls to update
or update_idletasks
.
The reasoning is simple: setting the overrideredirect
merely sets a flag. When the window is rendered, tkinter will look to see if the flag is set and then draw the window. If the flag is not set, a border is added to the window.
Setting the flag after the window has already been drawn will have no effect since the border will already have been drawn.