2016-03-05 33 views

回答

1

Bag of TK algorithms并且在这种google mailing list thread讨论:

toplevel .child 
    set parent . 
    set child .child 

    # This should display $child centered in $parent 
    set w [winfo width $parent] 
    set h [winfo height $parent] 
    set x [winfo rootx $parent] 
    set y [winfo rooty $parent] 
    set xpos "+[ expr {$x+($w-[winfo width $child])/2}]" 
    set ypos "+[ expr {$y+($h-[winfo height $child])/2}]" 

    wm geometry $child "$xpos$ypos"