[Tkinter-discuss] Determining size of a widget in grid?

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Tue Feb 19 09:50:31 CET 2008


Peter Milliken wrote:
> I have an application which uses the grid layout manager. One of my
> widgets can grow (and shrink) in width as various events in the
> application occur.
> 
> Is there anyway to determine the width of the widget in terms of the
> column width that the grid manager determines? i.e. the grid manager
> calculates a column width based on the widgets placed in it - I would
> like to determine if the "new" width of the widget (as it grows/shrinks)
> requires a columnspan value or not and if it does, then how many columns
> should it span?
> 
> At the moment, as the width of the widget gets larger than the column
> size allocated in the "other" columns, it makes the widgets in the same
> column (but different rows) look untidy because that "column" is a
> different size to the others (the "other" widgets are of a uniform size
> - it is just this one widget that grows/shrinks that is out of play in
> the grid/table layout).
> 
> Hope this is understandable :-)
> 
> Peter

Peter,

Not 100% sure I follow everything you're saying ;)

Take a look at the winfo_reqheight and winfo_reqwidth methods
you may have to call update_idletasks before calling them so
they are 'up to date'

There may also be some grid_ methods that can help, but I normally only
use pack so I'm afraid I can't be more specific

Martin


-- 
signature file not found, must be something I ate


More information about the Tkinter-discuss mailing list