[newbie] problem with geometry setting in Tkinter

Christian Gollwitzer auriocus at gmx.de
Mon Feb 8 10:11:50 EST 2016


Am 08.02.16 um 15:34 schrieb jenswaelkens at gmail.com:
> Op maandag 8 februari 2016 13:26:56 UTC+1 schreef Peter Otten:
>> jenswaelkens at gmail.com wrote:
>>
>>> I'm trying to set the geometry of my top window, but the size is
>>> unaffected.
>>> This is the code:
>>
>> top.geometry('900x460')
>>

>
> thanks a lot for helping me out

The answer is correct, however I think that in general it is wrong to 
set the geometry like this. grid and pack compute the necessary space 
for the window themselves, which adapts to the length of labels on 
buttons etc. In all GUI programs I've written, the only place to set 
window sizes in pixels have been canvas widgets, which do not have a 
native size derived from the content. Setting the size on the toplevel, 
and in absolute numbers, i.e. not computed from other sizes, is likely 
to lead to problems on different platforms, font sizes or theme changes.

	Christian




More information about the Python-list mailing list