[Tkinter] how to get the size of a column or a row of grid manager?
Jeff Epler
jepler at unpythonic.net
Sat May 17 23:47:12 EDT 2003
I don't believe it's possible directly. However, the Tk manpage for grid
mentions this:
grid location master x y
Given x and y values in screen units relative to the master
window, the column and row number at that x and y location is
returned. For locations that are above or to the left of the
grid, -1 is returned.
This is exposed as the method .grid_location(x,y). You could write
a method to return the width or height of a desired cell in terms of
this function.
Of course, for any widget contained in a row or column, you can use
.winfo_width()/.winfo_height() to find out how much space it's actually
using. (If sticky includes "ns", then the height is the same as the
height of that cell, and if sticky includes "ew", then the width is the
same as the width of that cell)
And you can use .grid_{row,column}configure to set the relative weights
of rows that expand when the user resizes the screen.
Jeff
More information about the Python-list
mailing list