[Tkinter-discuss] Correct order for dialog display

Vasilis Vlachoudis Vasilis.Vlachoudis at cern.ch
Thu Sep 30 09:30:27 CEST 2010


  Dear all,

In my application I have several custom made Toplevel windows when they 
close they remember their position and size, so the next time to open 
them using with the same geometry.

Therefore in the show method I have the following sequence

     def show(self):
         self.deiconify()
         self.geometry("%dx%d+%d+%d", self.width, self.height, self.x, 
self.y)
         self.wait_visibility()

In my linux Fedora-13, Ubuntu 10.04 etc.. works Ok.
However on Mac, Fedora-13 through a virtual machine (VirtualBox) or over 
the network the geometry card seems to be ignored.
The window appears to be where the window manager likes with size 
whatever Tk likes

If I change the order like
     self.wait_visibility()
     self.geometry("...")

then it works on all systems, BUT first it displays the window where the 
window manager likes with the standard size that Tk calculates AND THEN 
it move&resize to the correct position.

On fast machines is not a problem, but on slow machines or X11 over the 
network it becomes annoying.

So my question is:
     if I want to position and resize a Toplevel window (before it is 
shown), so when it is displayed to have the dimensions/position that I 
choose, what is the correct order of commands to use in order to work in 
all systems?

Thanks in advance
Vasilis



More information about the Tkinter-discuss mailing list