tkinter resize question

nickgeovanis at gmail.com nickgeovanis at gmail.com
Fri Jul 17 21:31:28 EDT 2015


On Friday, July 17, 2015 at 5:55:19 PM UTC-5, Terry Reedy wrote:
> On 7/17/2015 2:53 PM, nickgeovanis at gmail.com wrote:
> > Resizing a tkinter window which contains a frame which contains a
> > button widget, will not change the current size of the window, frame
> > or button as recorded in their height and width attributes (at least
> > not if they are resizable).
> 
> Post the code and experiments performed that leads you to believe the above.

It's really boring but here you are:

[ngeo at localhost src]$ python3
Python 3.4.2 (default, Dec 20 2014, 13:53:33) 
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> win=tkinter.Tk()
>>> frame=tkinter.Frame(win, bg="blue", width=200, height=200)
>>> butt1=tkinter.Button(fg="green", bg="black")
>>> frame.grid()
>>> butt1.grid()
>>> butt1["width"]
0
>>> butt1["height"]
0
>>> win["width"]
0
>>> win["height"]
0

Needless to say the button has appeared and has non-zero size.

>  > What is the correct way to detect their current size?
> 
> It is hard to fix code not posted.

Just a question from first principles: Find a widget's current size.
But the code example posted showed a working way to do the same thing.
Unfortunately requiring a function call, and not in the doc online AFAICS but....doc is doc.
 
> Terry Jan Reedy



More information about the Python-list mailing list