Reputation: 10930
I have created a label, which I placed in the center row and center column of a grid:
label .mytext -text "Hello!"
grid x x x -in .
grid x .mytext x
grid x x x -in .
grid rowconfigure . 0 -weight 1
grid rowconfigure . 1 -weight 1
grid rowconfigure . 2 -weight 1
grid columnconfigure . 0 -weight 1
grid columnconfigure . 1 -weight 1
grid columnconfigure . 2 -weight 1
wm geometry . 300x200
However, the label does not appear exactly at the center of the window; it is above the center:
Why is the label not exactly at the center of the window, even though I have placed it in the center of the grid?
Upvotes: 0
Views: 85
Reputation: 4813
Your grid x x x -in .
command effectively does nothing. The grid x .mytext x
command puts the label in the first empty row, which is row 0. You can verify this with grid info .mytext
.
To achieve what you seem to be trying, you can do:
label .mytext -text "Hello!"
grid .mytext -row 1 -column 1
grid rowconfigure . {0 1 2} -weight 1
grid columnconfigure . {0 1 2} -weight 1
wm geometry . 300x200
When doing it that way, the label does end up centered.
Upvotes: 2