[Tkinter-discuss] Correct order for dialog display

Bob Greschke bob at greschke.com
Thu Sep 30 17:06:49 CEST 2010


The .withdraw() should be right after the statement that creates the Toplevel window.  Creating it, then making the call to this def show() is giving the system time to make the window visible.  If the Toplevel() and the .withdraw() are together the window doesn't show up until the .deiconify().


On 2010-09-30, at 10:11, Vasilis Vlachoudis wrote:

> Thank you Michael for the suggestion,
> 
> I don't understand why you are using the withdraw() before.
> Now on my linux, it pops up the window (with Tk dimensions) then it remove it and then it displays it correctly with my dimensions.
> 
> Cheers
> Vasilis
> 
> 
> On 09/30/10 11:38, Michael Lange wrote:
>> Hi,
>> 
>> Thus spoketh Vasilis Vlachoudis<Vasilis.Vlachoudis at cern.ch>
>> unto us on Thu, 30 Sep 2010 09:30:27 +0200:
>> 
>>>   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()
>>> 
>> You might try to change your func like this:
>> 
>> def show(self):
>>     self.withdraw()
>>     self.geometry("%dx%d+%d+%d", self.width, self.height, self.x,self.y)
>>     self.update_idletasks()
>>     self.deiconify()
>> 
>> This way you should be able to avoid the ugly visible resizing, at least
>> I have used this successfully on X, I don't have any experience with
>> VirtualBox, though.
>> 
>> I hope this helps
>> 
>> Michael
>> 
>> 
>> .-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.
>> 
>> The only solution is ... a balance of power.  We arm our side with exactly
>> that much more.  A balance of power -- the trickiest, most difficult,
>> dirtiest game of them all.  But the only one that preserves both sides.
>> 		-- Kirk, "A Private Little War", stardate 4211.8
>> _______________________________________________
>> Tkinter-discuss mailing list
>> Tkinter-discuss at python.org
>> http://mail.python.org/mailman/listinfo/tkinter-discuss
> 
> -- 
> -------------------------------------------------------
> Vasilis Vlachoudis
> Dep. EN-STI-EET
> Web: home.cern.ch/bnv
> Tel: +41-22-7679851
> Fax: +41-22-7669644
> -------------------------------------------------------
> 
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
> 




More information about the Tkinter-discuss mailing list