Troubleshoot tcl / tk when using a grid

The reason I'm doing this is because I am trying to set the window in the center of the screen. I use grid not pack, and I read about using wm grid, but don’t understand how to install it. I also don’t understand why it . cget -widthreturns. 0I thought the grid should have set the size if the parameter was not set?

set width [. cget -width]
set height [. cget -height]
puts $height
puts $width
set x [expr { ( [winfo vrootwidth  .] - $width  ) / 2 }]
set y [expr { ( [winfo vrootheight .] - $height ) / 2 }]


wm title . "a3q2" 
wm geometry . ${width}x${height}+${x}+${y}

What am I doing wrong this time? PS homework I do not just want to write code. Thanks

+3
source share
2 answers

[. cget -width] [. cget -height] / . Tk . "" /, . , / , . , .

, [winfo width .] [winfo height .]. , , ( , [update] [winfo ...]). , , /.

+5

: [] . . Tcl , . <configure> event [winfo...] script.

0

All Articles