📄 pack.test
字号:
# This file is a Tcl script to test out the "pack" command# of Tk. It is organized in the standard fashion for Tcl tests.## Copyright (c) 1993 The Regents of the University of California.# Copyright (c) 1994 Sun Microsystems, Inc.## See the file "license.terms" for information on usage and redistribution# of this file, and for a DISCLAIMER OF ALL WARRANTIES.## SCCS: @(#) pack.test 1.27 97/07/01 18:06:56if {[string compare test [info procs test]] == 1} then \ {source defs}# Utility procedures:proc pack1 {args} { pack forget .pack.a .pack.b .pack.c .pack.d eval pack .pack.a $args pack .pack.b -expand yes -fill both update list [winfo geometry .pack.a] [winfo geometry .pack.b]}proc pack2 {args} { pack forget .pack.a .pack.b .pack.c .pack.d eval pack .pack.a $args update winfo geometry .pack.a}proc pack3 {args} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a -side top pack .pack.c -side left eval pack .pack.b $args update winfo geometry .pack.b}proc pack4 {option value} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a $option $value set i [pack info .pack.a] lindex $i [expr [lsearch -exact $i $option]+1]}# Create some test windows.catch {destroy .pack}toplevel .packwm geom .pack 300x200+0+0wm minsize .pack 1 1update idletasksforeach i {a b c d} { frame .pack.$i label .pack.$i.label -text $i -relief raised place .pack.$i.label -relwidth 1.0 -relheight 1.0}.pack.a config -width 20 -height 40.pack.b config -width 50 -height 30.pack.c config -width 80 -height 80.pack.d config -width 40 -height 30test pack-1.1 {-side option} { pack1 -side top} {20x40+140+0 300x160+0+40}test pack-1.2 {-side option} { pack1 -side bottom} {20x40+140+160 300x160+0+0}test pack-1.3 {-side option} { pack1 -side left} {20x40+0+80 280x200+20+0}test pack-1.4 {-side option} { pack1 -side right} {20x40+280+80 280x200+0+0}test pack-2.1 {x padding and filling} { pack1 -side right -padx 20} {20x40+260+80 240x200+0+0}test pack-2.2 {x padding and filling} { pack1 -side right -ipadx 20} {60x40+240+80 240x200+0+0}test pack-2.3 {x padding and filling} { pack1 -side right -ipadx 5 -padx 10} {30x40+260+80 250x200+0+0}test pack-2.4 {x padding and filling} { pack1 -side right -padx 20 -fill x} {20x40+260+80 240x200+0+0}test pack-2.5 {x padding and filling} { pack1 -side right -ipadx 20 -fill x} {60x40+240+80 240x200+0+0}test pack-2.6 {x padding and filling} { pack1 -side right -ipadx 5 -padx 10 -fill x} {30x40+260+80 250x200+0+0}test pack-2.7 {x padding and filling} { pack1 -side top -padx 20} {20x40+140+0 300x160+0+40}test pack-2.8 {x padding and filling} { pack1 -side top -ipadx 20} {60x40+120+0 300x160+0+40}test pack-2.9 {x padding and filling} { pack1 -side top -ipadx 5 -padx 10} {30x40+135+0 300x160+0+40}test pack-2.10 {x padding and filling} { pack1 -side top -padx 20 -fill x} {260x40+20+0 300x160+0+40}test pack-2.11 {x padding and filling} { pack1 -side top -ipadx 20 -fill x} {300x40+0+0 300x160+0+40}test pack-2.12 {x padding and filling} { pack1 -side top -ipadx 5 -padx 10 -fill x} {280x40+10+0 300x160+0+40}set pad [winfo pixels .pack 1c]test pack-2.13 {x padding and filling} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a -padx 1c set x [pack info .pack.a] lindex $x [expr [lsearch -exact $x -padx]+1]} $padtest pack-2.14 {x padding and filling} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a -ipadx 1c set x [pack info .pack.a] lindex $x [expr [lsearch -exact $x -ipadx]+1]} $padtest pack-3.1 {y padding and filling} { pack1 -side right -pady 20} {20x40+280+80 280x200+0+0}test pack-3.2 {y padding and filling} { pack1 -side right -ipady 20} {20x80+280+60 280x200+0+0}test pack-3.3 {y padding and filling} { pack1 -side right -ipady 5 -pady 10} {20x50+280+75 280x200+0+0}test pack-3.4 {y padding and filling} { pack1 -side right -pady 20 -fill y} {20x160+280+20 280x200+0+0}test pack-3.5 {y padding and filling} { pack1 -side right -ipady 20 -fill y} {20x200+280+0 280x200+0+0}test pack-3.6 {y padding and filling} { pack1 -side right -ipady 5 -pady 10 -fill y} {20x180+280+10 280x200+0+0}test pack-3.7 {y padding and filling} { pack1 -side top -pady 20} {20x40+140+20 300x120+0+80}test pack-3.8 {y padding and filling} { pack1 -side top -ipady 20} {20x80+140+0 300x120+0+80}test pack-3.9 {y padding and filling} { pack1 -side top -ipady 5 -pady 10} {20x50+140+10 300x130+0+70}test pack-3.10 {y padding and filling} { pack1 -side top -pady 20 -fill y} {20x40+140+20 300x120+0+80}test pack-3.11 {y padding and filling} { pack1 -side top -ipady 20 -fill y} {20x80+140+0 300x120+0+80}test pack-3.12 {y padding and filling} { pack1 -side top -ipady 5 -pady 10 -fill y} {20x50+140+10 300x130+0+70}set pad [winfo pixels .pack 1c]test pack-3.13 {y padding and filling} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a -pady 1c set x [pack info .pack.a] lindex $x [expr [lsearch -exact $x -pady]+1]} $padtest pack-3.14 {y padding and filling} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a -ipady 1c set x [pack info .pack.a] lindex $x [expr [lsearch -exact $x -ipady]+1]} $padtest pack-4.1 {anchors} { pack2 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor n} {30x70+135+20}test pack-4.2 {anchors} { pack2 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor ne} {30x70+260+20}test pack-4.3 {anchors} { pack2 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor e} {30x70+260+65}test pack-4.4 {anchors} { pack2 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor se} {30x70+260+110}test pack-4.5 {anchors} { pack2 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor s} {30x70+135+110}test pack-4.6 {anchors} { pack2 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor sw} {30x70+10+110}test pack-4.7 {anchors} { pack2 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor w} {30x70+10+65}test pack-4.8 {anchors} { pack2 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor nw} {30x70+10+20}test pack-4.9 {anchors} { pack2 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor center} {30x70+135+65}# Repeat above tests, but with a frame that isn't at (0,0), so that# we can be sure that the frame offset is being added in correctly.test pack-5.1 {more anchors} { pack3 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor n} {60x60+160+60}test pack-5.2 {more anchors} { pack3 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor ne} {60x60+230+60}test pack-5.3 {more anchors} { pack3 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor e} {60x60+230+90}test pack-5.4 {more anchors} { pack3 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor se} {60x60+230+120}test pack-5.5 {more anchors} { pack3 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor s} {60x60+160+120}test pack-5.6 {more anchors} { pack3 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor sw} {60x60+90+120}test pack-5.7 {more anchors} { pack3 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor w} {60x60+90+90}test pack-5.8 {more anchors} { pack3 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor nw} {60x60+90+60}test pack-5.9 {more anchors} { pack3 -side top -ipadx 5 -padx 10 -ipady 15 -pady 20 -expand y -anchor center} {60x60+160+90}test pack-6.1 {-expand option} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a .pack.b .pack.c .pack.d -side left update list [winfo geometry .pack.a] [winfo geometry .pack.b] \ [winfo geometry .pack.c] [winfo geometry .pack.d]} {20x40+0+80 50x30+20+85 80x80+70+60 40x30+150+85}test pack-6.2 {-expand option} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a -side left -expand yes pack .pack.b -side left pack .pack.c .pack.d -side left -expand 1 update list [winfo geometry .pack.a] [winfo geometry .pack.b] \ [winfo geometry .pack.c] [winfo geometry .pack.d]} {20x40+18+80 50x30+56+85 80x80+124+60 40x30+241+85}test pack-6.3 {-expand option} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a .pack.b .pack.c .pack.d -side top update list [winfo geometry .pack.a] [winfo geometry .pack.b] \ [winfo geometry .pack.c] [winfo geometry .pack.d]} {20x40+140+0 50x30+125+40 80x80+110+70 40x30+130+150}test pack-6.4 {-expand option} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a -side top -expand yes pack .pack.b -side top pack .pack.c .pack.d -side top -expand 1 update list [winfo geometry .pack.a] [winfo geometry .pack.b] \ [winfo geometry .pack.c] [winfo geometry .pack.d]} {20x40+140+3 50x30+125+46 80x80+110+79 40x30+130+166}test pack-6.5 {-expand option} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a .pack.b .pack.c .pack.d -side right update list [winfo geometry .pack.a] [winfo geometry .pack.b] \ [winfo geometry .pack.c] [winfo geometry .pack.d]} {20x40+280+80 50x30+230+85 80x80+150+60 40x30+110+85}test pack-6.6 {-expand option} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a -side right -expand yes pack .pack.b -side right pack .pack.c .pack.d -side right -expand 1 update list [winfo geometry .pack.a] [winfo geometry .pack.b] \ [winfo geometry .pack.c] [winfo geometry .pack.d]} {20x40+262+80 50x30+194+85 80x80+95+60 40x30+18+85}test pack-6.7 {-expand option} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a .pack.b .pack.c .pack.d -side bottom update list [winfo geometry .pack.a] [winfo geometry .pack.b] \ [winfo geometry .pack.c] [winfo geometry .pack.d]} {20x40+140+160 50x30+125+130 80x80+110+50 40x30+130+20}test pack-6.8 {-expand option} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a -side bottom -expand yes pack .pack.b -side bottom pack .pack.c .pack.d -side bottom -expand 1 update list [winfo geometry .pack.a] [winfo geometry .pack.b] \ [winfo geometry .pack.c] [winfo geometry .pack.d]} {20x40+140+157 50x30+125+124 80x80+110+40 40x30+130+3}test pack-6.9 {-expand option} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a -side bottom -expand yes -fill both pack .pack.b -side right pack .pack.c -side top -expand 1 -fill both pack .pack.d -side left update list [winfo geometry .pack.a] [winfo geometry .pack.b] \ [winfo geometry .pack.c] [winfo geometry .pack.d]} {300x65+0+135 50x30+250+52 250x105+0+0 40x30+0+105}test pack-6.10 {-expand option} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a -side left -expand yes -fill both pack .pack.b -side top pack .pack.c -side right -expand 1 -fill both pack .pack.d -side bottom update list [winfo geometry .pack.a] [winfo geometry .pack.b] \ [winfo geometry .pack.c] [winfo geometry .pack.d]} {100x200+0+0 50x30+175+0 160x170+140+30 40x30+100+170}test pack-6.11 {-expand option} { pack forget .pack.a .pack.b .pack.c .pack.d pack .pack.a -side left -expand yes -fill both pack .pack.b -side top -expand yes -fill both pack .pack.c -side right -expand 1 -fill both pack .pack.d -side bottom -expand yes -fill both update
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -