📄 grid.test
字号:
grid_reset 8.3test grid-8.4 {size} { catch {unset a} scale .f grid .f -row 0 -column 0 update lappend a [grid size .] grid .f -row 4 -column 5 update lappend a [grid size .] grid .f -row 947 -column 663 update lappend a [grid size .] grid .f -row 0 -column 0 update lappend a [grid size .] set a} {{1 1} {6 5} {664 948} {1 1}}grid_reset 8.4test grid-8.5 {size} { catch {unset a} scale .f grid .f -row 0 -column 0 update lappend a [grid size .] grid rowconfigure . 17 -weight 1 update lappend a [grid size .] grid columnconfigure . 63 -weight 1 update lappend a [grid size .] grid columnconfigure . 63 -weight 0 grid rowconfigure . 17 -weight 0 update lappend a [grid size .] set a} {{1 1} {1 18} {64 18} {1 1}}grid_reset 8.5test grid-8.6 {size} { catch {unset a} scale .f grid .f -row 10 -column 50 update lappend a [grid size .] grid columnconfigure . 15 -weight 1 grid columnconfigure . 30 -weight 1 update lappend a [grid size .] grid .f -row 10 -column 20 update lappend a [grid size .] grid columnconfigure . 30 -weight 0 update lappend a [grid size .] grid .f -row 0 -column 0 update lappend a [grid size .] grid columnconfigure . 15 -weight 0 update lappend a [grid size .] set a} {{51 11} {51 11} {31 11} {21 11} {16 1} {1 1}}grid_reset 8.6test grid-9.1 {slaves} { list [catch {grid slaves .} msg] $msg} {0 {}}test grid-9.2 {slaves} { list [catch {grid slaves .foo} msg] $msg} {1 {bad window path name ".foo"}}test grid-9.3 {slaves} { list [catch {grid slaves a b} msg] $msg} {1 {wrong # args: should be "grid slaves window ?-option value...?"}}test grid-9.4 {slaves} { list [catch {grid slaves . a b} msg] $msg} {1 {invalid args: should be "grid slaves window ?-option value...?"}}test grid-9.5 {slaves} { list [catch {grid slaves . -foo x} msg] $msg} {1 {expected integer but got "x"}}test grid-9.6 {slaves} { list [catch {grid slaves . -foo -3} msg] $msg} {1 {-foo is an invalid value: should NOT be < 0}}test grid-9.7 {slaves} { list [catch {grid slaves . -foo 3} msg] $msg} {1 {-foo is an invalid option: should be "-row, -column"}}test grid-9.8 {slaves} { list [catch {grid slaves .x -row 3} msg] $msg} {1 {bad window path name ".x"}}test grid-9.9 {slaves} { list [catch {grid slaves . -row 3} msg] $msg} {0 {}}test grid-9.10 {slaves} { foreach i {0 1 2} { label .$i -text $i grid .$i -row $i -column $i } list [catch {grid slaves .} msg] $msg} {0 {.2 .1 .0}}grid_reset 9.10test grid-9.11 {slaves} { catch {unset a} foreach i {0 1 2} { label .$i -text $i label .$i-x -text $i-x grid .$i -row $i -column $i grid .$i-x -row $i -column [incr i] } foreach row {0 1 2 3} { lappend a $row{[grid slaves . -row $row]} } foreach col {0 1 2 3} { lappend a $col{[grid slaves . -column $col]} } set a} {{0{.0-x .0}} {1{.1-x .1}} {2{.2-x .2}} 3{} 0{.0} {1{.1 .0-x}} {2{.2 .1-x}} 3{.2-x}} grid_reset 9.11# column/row configuretest grid-10.1 {column/row configure} { list [catch {grid columnconfigure .} msg] $msg} {1 {wrong # args: should be "grid columnconfigure master index ?-option value...?"}}grid_reset 10.1test grid-10.2 {column/row configure} { list [catch {grid columnconfigure . 0 -weight 0 -pad} msg] $msg} {1 {wrong # args: should be "grid columnconfigure master index ?-option value...?"}}grid_reset 10.2test grid-10.3 {column/row configure} { list [catch {grid columnconfigure .f 0 -weight} msg] $msg} {1 {bad window path name ".f"}}grid_reset 10.3test grid-10.4 {column/row configure} { list [catch {grid columnconfigure . nine -weight} msg] $msg} {1 {expected integer but got "nine"}}grid_reset 10.4test grid-10.5 {column/row configure} { list [catch {grid columnconfigure . 265 -weight} msg] $msg} {0 0}grid_reset 10.5test grid-10.6 {column/row configure} { list [catch {grid columnconfigure . 0} msg] $msg} {0 {-minsize 0 -pad 0 -weight 0}}grid_reset 10.6test grid-10.7 {column/row configure} { list [catch {grid columnconfigure . 0 -foo} msg] $msg} {1 {invalid arg "-foo": expecting -minsize, -pad, or -weight.}}grid_reset 10.7test grid-10.8 {column/row configure} { list [catch {grid columnconfigure . 0 -minsize foo} msg] $msg} {1 {bad screen distance "foo"}}grid_reset 10.8test grid-10.9 {column/row configure} { list [catch {grid columnconfigure . 0 -minsize foo} msg] $msg} {1 {bad screen distance "foo"}}grid_reset 10.9test grid-10.10 {column/row configure} { grid columnconfigure . 0 -minsize 10 grid columnconfigure . 0 -minsize} {10}grid_reset 10.10test grid-10.11 {column/row configure} { list [catch {grid columnconfigure . 0 -weight bad} msg] $msg} {1 {expected integer but got "bad"}}grid_reset 10.10atest grid-10.12 {column/row configure} { list [catch {grid columnconfigure . 0 -weight -3} msg] $msg} {1 {invalid arg "-weight": should be non-negative}}grid_reset 10.11test grid-10.13 {column/row configure} { grid columnconfigure . 0 -weight 3 grid columnconfigure . 0 -weight} {3}grid_reset 10.12test grid-10.14 {column/row configure} { list [catch {grid columnconfigure . 0 -pad foo} msg] $msg} {1 {bad screen distance "foo"}}grid_reset 10.13test grid-10.15 {column/row configure} { list [catch {grid columnconfigure . 0 -pad -3} msg] $msg} {1 {invalid arg "-pad": should be non-negative}}grid_reset 10.14test grid-10.16 {column/row configure} { grid columnconfigure . 0 -pad 3 grid columnconfigure . 0 -pad} {3}grid_reset 10.15test grid-10.17 {column/row configure} { frame .f set a "" grid columnconfigure .f 0 -weight 0 lappend a [grid columnconfigure .f 0 -weight] grid columnconfigure .f 0 -weight 1 lappend a [grid columnconfigure .f 0 -weight] grid rowconfigure .f 0 -weight 0 lappend a [grid rowconfigure .f 0 -weight] grid rowconfigure .f 0 -weight 1 lappend a [grid columnconfigure .f 0 -weight] grid columnconfigure .f 0 -weight 0 set a} {0 1 0 1}grid_reset 10.16test grid-10.18 {column/row configure} { frame .f grid columnconfigure .f 0 -minsize 10 -weight 1 list [grid columnconfigure .f 0 -minsize] \ [grid columnconfigure .f 1 -minsize] \ [grid columnconfigure .f 0 -weight] \ [grid columnconfigure .f 1 -weight]} {10 0 1 0}grid_reset 10.17# auto-placement teststest grid-11.1 {default widget placement} { list [catch {grid ^} msg] $msg} {1 {can't use '^', cant find master}}grid_reset 11.1test grid-11.2 {default widget placement} { button .b list [catch {grid .b ^} msg] $msg} {1 {can't find slave to extend with "^".}}grid_reset 11.2test grid-11.3 {default widget placement} { button .b list [catch {grid .b - - .c} msg] $msg} {1 {bad window path name ".c"}}grid_reset 11.3test grid-11.4 {default widget placement} { button .b list [catch {grid .b - - = -} msg] $msg} {1 {invalid window shortcut, "=" should be '-', 'x', or '^'}}grid_reset 11.4test grid-11.5 {default widget placement} { button .b list [catch {grid .b - x -} msg] $msg} {1 {Must specify window before shortcut '-'.}}grid_reset 11.5test grid-11.6 {default widget placement} { foreach i {1 2 3 4 5 6} { frame .f$i -width 50 -height 50 -highlightthickness 0 -bg red } grid .f1 .f2 .f3 .f4 grid .f5 - x .f6 -sticky nsew update set a "" foreach i {5 6} { lappend a "[winfo x .f$i],[winfo y .f$i] \ [winfo width .f$i],[winfo height .f$i]" } set a} {{0,50 100,50} {150,50 50,50}}grid_reset 11.6test grid-11.7 {default widget placement} { frame .f -width 20 -height 20 -highlightthickness 0 -bg red grid .f -row 5 -column 5 list [catch "grid .f x -" msg] $msg} {1 {Must specify window before shortcut '-'.}}grid_reset 11.7test grid-11.8 {default widget placement} { frame .f -width 20 -height 20 -highlightthickness 0 -bg red grid .f -row 5 -column 5 list [catch "grid .f ^ -" msg] $msg} {1 {Must specify window before shortcut '-'.}}grid_reset 11.8test grid-11.9 {default widget placement} { frame .f -width 20 -height 20 -highlightthickness 0 -bg red grid .f -row 5 -column 5 list [catch "grid .f x ^" msg] $msg} {1 {can't find slave to extend with "^".}}grid_reset 11.9test grid-11.10 {default widget placement} { foreach i {1 2 3} { frame .f$i -width 100 -height 50 -highlightthickness 0 -bg red } grid .f1 .f2 -sticky nsew grid .f3 ^ -sticky nsew update set a "" foreach i {1 2 3} { lappend a "[winfo x .f$i],[winfo y .f$i] \ [winfo width .f$i],[winfo height .f$i]" } set a} {{0,0 100,50} {100,0 100,100} {0,50 100,50}}grid_reset 11.10test grid-11.11 {default widget placement} { foreach i {1 2 3 4 5 6 7 8 9 10 11 12} { frame .f$i -width 50 -height 50 -highlightthickness 1 -highlightbackground black } grid .f1 .f2 .f3 .f4 -sticky nsew grid .f5 .f6 - .f7 -sticky nsew grid .f8 ^ ^ .f9 -sticky nsew grid .f10 ^ ^ .f11 -sticky nsew grid .f12 - - - -sticky nsew update set a "" foreach i {5 6 7 8 9 10 11 12 } { lappend a "[winfo x .f$i],[winfo y .f$i] \ [winfo width .f$i],[winfo height .f$i]" } set a} {{0,50 50,50} {50,50 100,150} {150,50 50,50} {0,100 50,50} {150,100 50,50} {0,150 50,50} {150,150 50,50} {0,200 200,50}}grid_reset 11.11test grid-11.12 {default widget placement} { foreach i {1 2 3 4} { frame .f$i -width 75 -height 50 -highlightthickness 1 -highlightbackground black } grid .f1 .f2 .f3 -sticky nsew grid .f4 ^ -sticky nsew update set a "" foreach i {1 2 3 4} { lappend a "[winfo x .f$i],[winfo y .f$i] \ [winfo width .f$i],[winfo height .f$i]" } grid .f4 ^ -column 1 update foreach i {1 2 3 4} { lappend a "[winfo x .f$i],[winfo y .f$i] \ [winfo width .f$i],[winfo height .f$i]" } set a} {{0,0 75,50} {75,0 75,100} {150,0 75,50} {0,50 75,50} {0,0 75,50} {75,0 75,100} {150,0 75,100} {75,50 75,50}}grid_reset 11.12test grid-11.13 {default widget placement} { foreach i {1 2 3 4 5 6 7} { frame .f$i -width 40 -height 50 -highlightthickness 1 -highlightbackground black } grid .f1 .f2 .f3 .f4 .f5 -sticky nsew grid .f6 - .f7 -sticky nsew -columnspan 2 update set a "" foreach i {6 7} { lappend a "[winfo x .f$i],[winfo y .f$i] \ [winfo width .f$i],[winfo height .f$i]" } set a} {{0,50 120,50} {120,50 80,50}}grid_reset 11.13test grid-11.14 {default widget placement} { foreach i {1 2 3} { frame .f$i -width 50 -height 50 -highlightthickness 0 -bg red } grid .f1 .f2 grid ^ .f3 update set a "" foreach i {1 2 3} { lappend a "[winfo x .f$i],[winfo y .f$i] \ [winfo width .f$i],[winfo height .f$i]" } set a} {{0,25 50,50} {50,0 50,50} {50,50 50,50}}grid_reset 11.14test grid-12.1 {-sticky} { catch {unset data} frame .f -width 200 -height 100 -highlightthickness 0 -bg red set a ""
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -