I have a frame defined within root and a TkLabel widget inside the
frame. I used pack to set the location of the frame within root and am
trying to use grid to set the location of the label in the frame. When
I set the grid loaction to column 1, row 1 it remains centered in the
page. I included "sticky => ‘w’ as an option to grid but it doesn’t
seem to work. The code I used is below. Any reason why column 1 is in
the middle of the page when it is resized?
When
I set the grid loaction to column 1, row 1 it remains centered in the
page. I included "sticky => ‘w’ as an option to grid but it doesn’t
seem to work. The code I used is below. Any reason why column 1 is in
the middle of the page when it is resized?
Please read “THE GRID ALGORITHM” in the man of grid (man n grid).
You’ll have to set the proper values to ‘weight’ options of the
columns (e.g. date.grid_columnconfigure(1, :weight=>1) ).
Please read “THE GRID ALGORITHM” in the man of grid (man n grid).
You’ll have to set the proper values to ‘weight’ options of the
columns (e.g. date.grid_columnconfigure(1, :weight=>1) ).
Ok, that makes sense. I read through that quickly but didn’t make the
connection. I am not exactly sure what the master index is though. If
I have a frame(=top) within root and several frames within ‘top’, what
would the master index refer to? Thanks for the help.
Ok, that makes sense. I read through that quickly but didn’t make the
connection. I am not exactly sure what the master index is though. If
I have a frame(=top) within root and several frames within ‘top’, what
would the master index refer to? Thanks for the help.
Maybe, I’m misunderstanding your question.
First of all, the followings are same.
NOTE: ‘date’ in the case of Tcl/Tk means the widget path of
the ‘date’ frame widget.
In those cases, the master is the frame widget ‘date’.
And the index is 1, that is, the 2nd column of the grid table.
( the index of 1st column is 0. )
The default weight value of each column is 0.
All of those columns aren’t assigned free area arised from
resizing the master (‘date’ frame).
So, the small grid table is placed at the center of the master,
and has free areas at each side.
After calling the columnconfigure, the free area is allocated
by the weight ratio ( column0 : column1 = 0 : 1 ).
It enlarges the width of column1 only.
And now, the ‘sticky’ option gets the chance of working.
The area of the column1 is larger than the size of the label widget.
The label widget is placed depend on the value of ‘sticky’ option.