1 # This file is a Tcl script to test out the "frame" and "toplevel"
2 # commands of Tk. It is organized in the standard fashion for Tcl
5 # Copyright (c) 1994 The Regents of the University of California.
6 # Copyright (c) 1994-1996 Sun Microsystems, Inc.
7 # Copyright (c) 1998-1999 by Scriptics Corporation.
10 package require tcltest 2.2
11 namespace import ::tcltest::*
12 eval tcltest::configure $argv
13 tcltest::loadTestedCommands
16 # Creates a toplevel window and allocates enough colors in it to
17 # use up all the slots in the colormap.
20 # w - Name of toplevel window to create.
26 canvas $w.c -width 400 -height 200 -bd 0
28 for {set y 0} {$y < 8} {incr y} {
29 for {set x 0} {$x < 40} {incr x} {
30 set color [format #%02x%02x%02x [expr $x*6] [expr $y*30] 0]
31 $w.c create rectangle [expr 10*$x] [expr 20*$y] \
32 [expr 10*$x + 10] [expr 20*$y + 20] -outline {} \
41 # Returns 1 if there appear to be free colormap entries in a window,
45 # w - Name of window in which to check.
46 # red, green, blue - Intensities to use in a trial color allocation
47 # to see if there are colormap entries free.
49 proc colorsFree {w {red 31} {green 245} {blue 192}} {
50 set vals [winfo rgb $w [format #%02x%02x%02x $red $green $blue]]
51 expr ([lindex $vals 0]/256 == $red) && ([lindex $vals 1]/256 == $green) \
52 && ([lindex $vals 2]/256 == $blue)
56 test frame-1.1 {frame configuration options} -setup {
59 frame .f -class NewFrame
63 } -result {-class class Class Frame NewFrame}
64 test frame-1.2 {frame configuration options} -setup {
67 frame .f -class NewFrame
68 .f configure -class Different
71 } -returnCodes error -result {can't modify -class option after widget is created}
73 test frame-1.3 {frame configuration options} -setup {
76 frame .f -colormap new
77 .f configure -colormap
80 } -result {-colormap colormap Colormap {} new}
81 test frame-1.4 {frame configuration options} -setup {
84 frame .f -colormap new
85 .f configure -colormap .
88 } -returnCodes error -result {can't modify -colormap option after widget is created}
90 test frame-1.5 {frame configuration options} -setup {
93 frame .f -visual default
97 } -result {-visual visual Visual {} default}
98 test frame-1.6 {frame configuration options} -setup {
101 frame .f -visual default
102 .f configure -visual best
105 } -returnCodes error -result {can't modify -visual option after widget is created}
107 test frame-1.7 {frame configuration options} -setup {
110 frame .f -screen bogus
113 } -returnCodes error -result {unknown option "-screen"}
114 test frame-1.8 {frame configuration options} -setup {
117 frame .f -container true
121 test frame-1.9 {frame configuration options} -setup {
124 frame .f -container true
125 .f configure -container
128 } -result {-container container Container 0 1}
129 test frame-1.10 {frame configuration options} -setup {
132 frame .f -container bogus
135 } -returnCodes error -result {expected boolean value but got "bogus"}
136 test frame-1.11 {frame configuration options} -setup {
140 .f configure -container 1
143 } -returnCodes error -result {can't modify -container option after widget is created}
144 test frame-1.12 {frame configuration options} -setup {
147 # Make sure all options can be set to the default value
150 foreach opt [.f configure] {
151 if {[llength $opt] == 5} {
152 lappend opts [lindex $opt 0] [lindex $opt 4]
163 test frame-1.13 {frame configuration options} -body {
164 .f configure -background #ff0000
165 lindex [.f configure -background] 4
167 .f configure -background [lindex [.f configure -background] 3]
169 test frame-1.14 {frame configuration options} -body {
170 .f configure -background non-existent
171 } -returnCodes error -result {unknown color name "non-existent"}
172 test frame-1.15 {frame configuration options} -body {
174 lindex [.f configure -bd] 4
176 .f configure -bd [lindex [.f configure -bd] 3]
178 test frame-1.16 {frame configuration options} -body {
179 .f configure -bd badValue
180 } -returnCodes error -result {bad screen distance "badValue"}
181 test frame-1.17 {frame configuration options} -body {
182 .f configure -bg #00ff00
183 lindex [.f configure -bg] 4
185 .f configure -bg [lindex [.f configure -bg] 3]
187 test frame-1.18 {frame configuration options} -body {
188 .f configure -bg non-existent
189 } -returnCodes error -result {unknown color name "non-existent"}
190 test frame-1.19 {frame configuration options} -body {
191 .f configure -borderwidth 1.3
192 lindex [.f configure -borderwidth] 4
194 .f configure -borderwidth [lindex [.f configure -borderwidth] 3]
196 test frame-1.20 {frame configuration options} -body {
197 .f configure -borderwidth badValue
198 } -returnCodes error -result {bad screen distance "badValue"}
199 test frame-1.21 {frame configuration options} -body {
200 .f configure -cursor arrow
201 lindex [.f configure -cursor] 4
203 .f configure -cursor [lindex [.f configure -cursor] 3]
205 test frame-1.22 {frame configuration options} -body {
206 .f configure -cursor badValue
207 } -returnCodes error -result {bad cursor spec "badValue"}
208 test frame-1.23 {frame configuration options} -body {
209 .f configure -height 100
210 lindex [.f configure -height] 4
212 .f configure -height [lindex [.f configure -height] 3]
214 test frame-1.24 {frame configuration options} -body {
215 .f configure -height not_a_number
216 } -returnCodes error -result {bad screen distance "not_a_number"}
217 test frame-1.25 {frame configuration options} -body {
218 .f configure -highlightbackground #112233
219 lindex [.f configure -highlightbackground] 4
221 .f configure -highlightbackground [lindex [.f configure -highlightbackground] 3]
223 test frame-1.26 {frame configuration options} -body {
224 .f configure -highlightbackground ugly
225 } -returnCodes error -result {unknown color name "ugly"}
226 test frame-1.27 {frame configuration options} -body {
227 .f configure -highlightcolor #123456
228 lindex [.f configure -highlightcolor] 4
230 .f configure -highlightcolor [lindex [.f configure -highlightcolor] 3]
232 test frame-1.28 {frame configuration options} -body {
233 .f configure -highlightcolor non-existent
234 } -returnCodes error -result {unknown color name "non-existent"}
235 test frame-1.29 {frame configuration options} -body {
236 .f configure -highlightthickness 6
237 lindex [.f configure -highlightthickness] 4
239 .f configure -highlightthickness [lindex [.f configure -highlightthickness] 3]
241 test frame-1.30 {frame configuration options} -body {
242 .f configure -highlightthickness badValue
243 } -returnCodes error -result {bad screen distance "badValue"}
244 test frame-1.31 {frame configuration options} -body {
246 lindex [.f configure -padx] 4
248 .f configure -padx [lindex [.f configure -padx] 3]
250 test frame-1.32 {frame configuration options} -body {
251 .f configure -padx badValue
252 } -returnCodes error -result {bad screen distance "badValue"}
253 test frame-1.33 {frame configuration options} -body {
255 lindex [.f configure -pady] 4
257 .f configure -pady [lindex [.f configure -pady] 3]
259 test frame-1.34 {frame configuration options} -body {
260 .f configure -pady badValue
261 } -returnCodes error -result {bad screen distance "badValue"}
262 test frame-1.35 {frame configuration options} -body {
263 .f configure -relief ridge
264 lindex [.f configure -relief] 4
266 .f configure -relief [lindex [.f configure -relief] 3]
268 test frame-1.36 {frame configuration options} -body {
269 .f configure -relief badValue
270 } -returnCodes error -result {bad relief "badValue": must be flat, groove, raised, ridge, solid, or sunken}
271 test frame-1.37 {frame configuration options} -body {
272 .f configure -takefocus {any string}
273 lindex [.f configure -takefocus] 4
275 .f configure -takefocus [lindex [.f configure -takefocus] 3]
276 } -result {any string}
277 test frame-1.38 {frame configuration options} -body {
278 .f configure -width 32
279 lindex [.f configure -width] 4
281 .f configure -width [lindex [.f configure -width] 3]
283 test frame-1.39 {frame configuration options} -body {
284 .f configure -width badValue
285 } -returnCodes error -result {bad screen distance "badValue"}
289 test frame-2.1 {toplevel configuration options} -setup {
292 toplevel .t -width 200 -height 100 -class NewClass
297 } -result {-class class Class Toplevel NewClass}
298 test frame-2.2 {toplevel configuration options} -setup {
301 toplevel .t -width 200 -height 100 -class NewClass
303 .t configure -class Another
306 } -returnCodes error -result {can't modify -class option after widget is created}
308 test frame-2.3 {toplevel configuration options} -setup {
311 toplevel .t -width 200 -height 100 -colormap new
313 .t configure -colormap
316 } -result {-colormap colormap Colormap {} new}
317 test frame-2.4 {toplevel configuration options} -setup {
320 toplevel .t -width 200 -height 100 -colormap new
322 .t configure -colormap .
325 } -returnCodes error -result {can't modify -colormap option after widget is created}
327 test frame-2.5 {toplevel configuration options} -setup {
330 toplevel .t -width 200 -height 100
332 .t configure -container 1
335 } -returnCodes error -result {can't modify -container option after widget is created}
336 test frame-2.6 {toplevel configuration options} -setup {
340 toplevel .t -width 200 -height 100
342 catch {.t configure -container 1}
343 .t configure -container
346 } -result {-container container Container 0 0}
348 test frame-2.7 {toplevel configuration options} -setup {
351 toplevel .t -width 200 -height 100 -colormap bogus
354 } -returnCodes error -result {bad window path name "bogus"}
357 test frame-2.8 {toplevel configuration options} -constraints {
363 toplevel .t -width 200 -height 100
365 .t configure -use 0x44022
368 } -returnCodes error -result {window "0x44022" doesn't exist}
369 test frame-2.9 {toplevel configuration options} -constraints {
375 toplevel .t -width 200 -height 100
377 catch {.t configure -use 0x44022}
381 } -result {-use use Use {} {}}
383 test frame-2.10 {toplevel configuration options} -constraints {
389 toplevel .t -width 200 -height 100
391 .t configure -use 0x44022
394 } -returnCodes error -result {can't modify -use option after widget is created}
395 test frame-2.11 {toplevel configuration options} -constraints {
401 toplevel .t -width 200 -height 100
403 catch {.t configure -use 0x44022}
407 } -result {-use use Use {} {}}
409 test frame-2.12 {toplevel configuration options} -setup {
413 toplevel .t -width 200 -height 100 -visual default
418 } -result {-visual visual Visual {} default}
419 test frame-2.13 {toplevel configuration options} -setup {
423 toplevel .t -width 200 -height 100 -visual default
425 .t configure -visual best
428 } -returnCodes error -result {can't modify -visual option after widget is created}
430 test frame-2.14 {toplevel configuration options} -setup {
433 toplevel .t -width 200 -height 100 -visual who_knows?
436 } -returnCodes error -result {unknown or ambiguous visual name "who_knows?": class must be best, directcolor, grayscale, greyscale, pseudocolor, staticcolor, staticgray, staticgrey, truecolor, or default}
437 test frame-2.15 {toplevel configuration options} -constraints haveDISPLAY -setup {
440 toplevel .t -width 200 -height 100 -screen $env(DISPLAY)
442 string compare [.t configure -screen] "-screen screen Screen {} $env(DISPLAY)"
446 test frame-2.16 {toplevel configuration options} -constraints haveDISPLAY -setup {
449 toplevel .t -width 200 -height 100 -screen $env(DISPLAY)
451 .t configure -screen another
454 } -returnCodes error -result {can't modify -screen option after widget is created}
456 test frame-2.17 {toplevel configuration options} -setup {
459 toplevel .t -width 200 -height 100 -screen bogus
462 } -returnCodes error -result {couldn't connect to display "bogus"}
463 test frame-2.18 {toplevel configuration options} -setup {
466 toplevel .t -container 1 -width 300 -height 120
468 toplevel .x -container 1 -use [winfo id .t]
471 } -returnCodes error -result {windows cannot have both the -use and the -container option set}
472 test frame-2.19 {toplevel configuration options} -setup {
476 # Make sure all options can be set to the default value
478 foreach opt [.f configure] {
479 if {[llength $opt] == 5} {
480 lappend opts [lindex $opt 0] [lindex $opt 4]
483 eval toplevel .g $opts
491 toplevel .t -width 300 -height 150
494 test frame-2.20 {toplevel configuration options} -body {
495 .t configure -background #ff0000
496 lindex [.t configure -background] 4
498 test frame-2.21 {toplevel configuration options} -body {
499 .t configure -background non-existent
500 } -returnCodes error -result {unknown color name "non-existent"}
501 test frame-2.22 {toplevel configuration options} -body {
503 lindex [.t configure -bd] 4
505 test frame-2.23 {toplevel configuration options} -body {
506 .t configure -bd badValue
507 } -returnCodes error -result {bad screen distance "badValue"}
508 test frame-2.24 {toplevel configuration options} -body {
509 .t configure -bg #00ff00
510 lindex [.t configure -bg] 4
512 test frame-2.25 {toplevel configuration options} -body {
513 .t configure -bg non-existent
514 } -returnCodes error -result {unknown color name "non-existent"}
515 test frame-2.26 {toplevel configuration options} -body {
516 .t configure -borderwidth 1.3
517 lindex [.t configure -borderwidth] 4
519 test frame-2.27 {toplevel configuration options} -body {
520 .t configure -borderwidth badValue
521 } -returnCodes error -result {bad screen distance "badValue"}
522 test frame-2.28 {toplevel configuration options} -body {
523 .t configure -cursor arrow
524 lindex [.t configure -cursor] 4
526 test frame-2.29 {toplevel configuration options} -body {
527 .t configure -cursor badValue
528 } -returnCodes error -result {bad cursor spec "badValue"}
529 test frame-2.30 {toplevel configuration options} -body {
530 .t configure -height 100
531 lindex [.t configure -height] 4
533 test frame-2.31 {toplevel configuration options} -body {
534 .t configure -height not_a_number
535 } -returnCodes error -result {bad screen distance "not_a_number"}
536 test frame-2.32 {toplevel configuration options} -body {
537 .t configure -highlightcolor #123456
538 lindex [.t configure -highlightcolor] 4
540 test frame-2.33 {toplevel configuration options} -body {
541 .t configure -highlightcolor non-existent
542 } -returnCodes error -result {unknown color name "non-existent"}
543 test frame-2.34 {toplevel configuration options} -body {
544 .t configure -highlightthickness 3
545 lindex [.t configure -highlightthickness] 4
547 test frame-2.35 {toplevel configuration options} -body {
548 .t configure -highlightthickness badValue
549 } -returnCodes error -result {bad screen distance "badValue"}
550 test frame-2.36 {toplevel configuration options} -body {
552 lindex [.t configure -padx] 4
554 test frame-2.37 {toplevel configuration options} -body {
555 .t configure -padx badValue
556 } -returnCodes error -result {bad screen distance "badValue"}
557 test frame-2.38 {toplevel configuration options} -body {
559 lindex [.t configure -pady] 4
561 test frame-2.39 {toplevel configuration options} -body {
562 .t configure -pady badValue
563 } -returnCodes error -result {bad screen distance "badValue"}
564 test frame-2.40 {toplevel configuration options} -body {
565 .t configure -relief ridge
566 lindex [.t configure -relief] 4
568 test frame-2.41 {toplevel configuration options} -body {
569 .t configure -relief badValue
570 } -returnCodes error -result {bad relief "badValue": must be flat, groove, raised, ridge, solid, or sunken}
571 test frame-2.42 {toplevel configuration options} -body {
572 .t configure -width 32
573 lindex [.t configure -width] 4
575 test frame-2.43 {toplevel configuration options} -body {
576 .t configure -width badValue
577 } -returnCodes error -result {bad screen distance "badValue"}
581 test frame-3.1 {TkCreateFrame procedure} -body {
583 } -returnCodes error -result {wrong # args: should be "frame pathName ?-option value ...?"}
584 test frame-3.2 {TkCreateFrame procedure} -setup {
591 } -result {-class class Class Frame Frame}
592 test frame-3.3 {TkCreateFrame procedure} -setup {
600 } -result {-class class Class Toplevel Toplevel}
601 test frame-3.4 {TkCreateFrame procedure} -setup {
604 toplevel .t -width 350 -class NewClass -bg black -visual default -height 90
607 list [lindex [.t configure -width] 4] \
608 [lindex [.t configure -background] 4] \
609 [lindex [.t configure -height] 4]
612 } -result {350 black 90}
614 # Be sure that the -class, -colormap, and -visual options are processed
615 # before configuring the widget.
616 test frame-3.5 {TkCreateFrame procedure} -setup {
619 option add *NewFrame.background #123456
620 frame .f -class NewFrame
621 lindex [.f configure -background] 4
626 test frame-3.7 {TkCreateFrame procedure} -setup {
629 option add *NewFrame.background #332211
630 option add *f.class NewFrame
632 list [lindex [.f configure -class] 4] [lindex [.f configure -background] 4]
636 } -result {NewFrame #332211}
637 test frame-3.8 {TkCreateFrame procedure} -setup {
640 option add *Silly.background #122334
641 option add *f.Class Silly
643 list [lindex [.f configure -class] 4] [lindex [.f configure -background] 4]
647 } -result {Silly #122334}
648 test frame-3.9 {TkCreateFrame procedure, -use option} -constraints {
653 toplevel .t -container 1 -width 300 -height 120
655 toplevel .x -width 140 -height 300 -use [winfo id .t] -bg green
657 list [expr {[winfo rootx .x] - [winfo rootx .t]}] \
658 [expr {[winfo rooty .x] - [winfo rooty .t]}] \
659 [winfo width .t] [winfo height .t]
661 # This call to update idletasks was added to prevent a crash that was
662 # observed on OSX 10.12 (Sierra) only. Any change, such as using the
663 # Development version to make debugging symbols available, adding a print
664 # statement, or calling update idletasks here, would make the test pass
668 } -result {0 0 140 300}
669 test frame-3.10 {TkCreateFrame procedure, -use option} -constraints {
674 toplevel .t -container 1 -width 300 -height 120
676 if {[tk windowingsystem] eq "aqua"} {
681 option add *x.use [winfo id .t]
682 toplevel .x -width 140 -height 300 -bg green
683 if {[tk windowingsystem] eq "aqua"} {
689 list [expr {[winfo rootx .x] - [winfo rootx .t]}] \
690 [expr {[winfo rooty .x] - [winfo rooty .t]}] \
691 [winfo width .t] [winfo height .t]
695 } -result {0 0 140 300}
697 # The tests below require specific display characteristics (i.e. that
698 # they are run on a pseudocolor display of depth 8). Even so, they
699 # are non-portable: some machines don't seem to ever run out of
701 if {[testConstraint defaultPseudocolor8]} {
704 test frame-3.11 {TkCreateFrame procedure} -constraints {
705 defaultPseudocolor8 nonPortable
709 toplevel .t -width 300 -height 200 -bg #475601
716 test frame-3.12 {TkCreateFrame procedure} -constraints {
717 defaultPseudocolor8 nonPortable
721 toplevel .t -width 300 -height 200 -bg #475601 -colormap new
728 test frame-3.13 {TkCreateFrame procedure} -constraints {
729 defaultPseudocolor8 nonPortable
733 option add *t.class Toplevel2
734 option add *Toplevel2.colormap new
735 toplevel .t -width 300 -height 200 -bg #475601
743 test frame-3.14 {TkCreateFrame procedure} -constraints {
744 defaultPseudocolor8 nonPortable
748 option add *t.class Toplevel3
749 option add *Toplevel3.Colormap new
750 toplevel .t -width 300 -height 200 -bg #475601 -colormap new
758 test frame-3.15 {TkCreateFrame procedure, -use and -colormap} -constraints {
759 defaultPseudocolor8 unix nonPortable
763 toplevel .t -container 1 -width 300 -height 120
765 toplevel .x -width 140 -height 300 -use [winfo id .t] -bg green -colormap new
767 list [colorsFree .t] [colorsFree .x]
771 test frame-3.16 {TkCreateFrame procedure} -constraints {
772 defaultPseudocolor8 nonPortable
776 toplevel .t -width 300 -height 200 -bg #475601 -visual default
783 test frame-3.17 {TkCreateFrame procedure} -constraints {
784 defaultPseudocolor8 nonPortable
788 toplevel .t -width 300 -height 200 -bg #475601 -visual default \
796 test frame-3.18 {TkCreateFrame procedure} -constraints {
797 defaultPseudocolor8 haveGrayscale8 nonPortable
801 toplevel .t -visual {grayscale 8} -width 300 -height 200 -bg #434343
804 colorsFree .t 131 131 131
808 test frame-3.19 {TkCreateFrame procedure} -constraints {
809 defaultPseudocolor8 haveGrayscale8 nonPortable
813 option add *t.class T4
814 option add *T4.visual {grayscale 8}
815 toplevel .t -width 300 -height 200 -bg #434343
819 list [colorsFree .t 131 131 131] [lindex [.t configure -visual] 4]
822 } -result {1 {grayscale 8}}
823 test frame-3.20 {TkCreateFrame procedure} -constraints {
824 defaultPseudocolor8 haveGrayscale8 nonPortable
829 option add *t.class T5
830 option add *T5.Visual {grayscale 8}
831 toplevel .t -width 300 -height 200 -bg #434343
835 list [colorsFree .t 131 131 131] [lindex [.t configure -visual] 4]
838 } -result {1 {grayscale 8}}
839 test frame-3.21 {TkCreateFrame procedure} -constraints {
840 defaultPseudocolor8 haveGrayscale8 nonPortable
845 toplevel .t -visual {grayscale 8} -width 300 -height 200 -bg #434343
848 colorsFree .t 131 131 131
852 if {[testConstraint defaultPseudocolor8]} {
856 test frame-3.22 {TkCreateFrame procedure, default dimensions} -setup {
862 set result "[winfo reqwidth .t] [winfo reqheight .t]"
866 lappend result [winfo reqwidth .t.f] [winfo reqheight .t.f]
869 } -result {200 200 1 1}
870 test frame-3.23 {TkCreateFrame procedure} -setup {
874 } -returnCodes error -result {unknown option "-gorp"}
875 test frame-3.24 {TkCreateFrame procedure} -setup {
878 toplevel .t -width 300 -height 200 -colormap new -bogus option
880 } -returnCodes error -result {unknown option "-bogus"}
883 test frame-4.1 {TkCreateFrame procedure} -setup {
886 catch {frame .f -gorp glob}
889 test frame-4.2 {TkCreateFrame procedure} -setup {
892 list [frame .f -width 200 -height 100] [winfo exists .f]
898 frame .f -highlightcolor black
899 test frame-5.1 {FrameWidgetCommand procedure} -body {
901 } -returnCodes error -result {wrong # args: should be ".f option ?arg ...?"}
902 test frame-5.2 {FrameWidgetCommand procedure, cget option} -body {
904 } -returnCodes error -result {wrong # args: should be ".f cget option"}
905 test frame-5.3 {FrameWidgetCommand procedure, cget option} -body {
907 } -returnCodes error -result {wrong # args: should be ".f cget option"}
908 test frame-5.4 {FrameWidgetCommand procedure, cget option} -body {
910 } -returnCodes error -result {unknown option "-gorp"}
911 test frame-5.5 {FrameWidgetCommand procedure, cget option} -body {
912 .f cget -highlightcolor
914 test frame-5.6 {FrameWidgetCommand procedure, cget option} -body {
916 } -returnCodes error -result {unknown option "-screen"}
917 test frame-5.7 {FrameWidgetCommand procedure, cget option} -setup {
924 } -returnCodes ok -match glob -result *
926 test frame-5.8 {FrameWidgetCommand procedure, configure option} -body {
927 llength [.f configure]
929 test frame-5.9 {FrameWidgetCommand procedure, configure option} -body {
931 } -returnCodes error -result {unknown option "-gorp"}
932 test frame-5.10 {FrameWidgetCommand procedure, configure option} -body {
933 .f configure -gorp bogus
934 } -returnCodes error -result {unknown option "-gorp"}
935 test frame-5.11 {FrameWidgetCommand procedure, configure option} -body {
936 .f configure -width 200 -height
937 } -returnCodes error -result {value for "-height" missing}
938 test frame-5.12 {FrameWidgetCommand procedure} -body {
940 } -returnCodes error -result {bad option "swizzle": must be cget or configure}
941 test frame-5.13 {FrameWidgetCommand procedure, configure option} -body {
942 llength [. configure]
946 test frame-6.1 {ConfigureFrame procedure} -setup {
950 list [winfo reqwidth .f] [winfo reqheight .f]
954 test frame-6.2 {ConfigureFrame procedure} -setup {
958 list [winfo reqwidth .f] [winfo reqheight .f]
962 test frame-6.3 {ConfigureFrame procedure} -setup {
967 lappend result [winfo reqwidth .f] [winfo reqheight .f]
968 .f configure -width 100 -height 180
969 lappend result [winfo reqwidth .f] [winfo reqheight .f]
970 .f configure -width 0 -height 0
971 lappend result [winfo reqwidth .f] [winfo reqheight .f]
974 } -result {1 1 100 180 100 180}
976 test frame-7.1 {FrameEventProc procedure} -setup {
980 set result [info commands .frame2]
982 lappend result [info commands .frame2]
983 } -result {.frame2 {}}
984 test frame-7.2 {FrameEventProc procedure} -setup {
988 frame .f1 -bg #543210
990 lappend x [winfo children .]
991 lappend x [.f2 cget -bg]
993 lappend x [info command .f*] [winfo children .]
996 } -result {.f1 #543210 {} {}}
998 test frame-8.1 {FrameCmdDeletedProc procedure} -setup {
1003 list [info command .f*] [winfo children .]
1007 test frame-8.2 {FrameCmdDeletedProc procedure} -setup {
1010 toplevel .f1 -menu .m
1011 wm geometry .f1 +0+0
1015 list [info command .f*] [winfo children .]
1020 # This one fails with the dash-patch!!!! Still don't know why :-(
1022 #test frame-8.3 {FrameCmdDeletedProc procedure} -setup {
1023 # eval destroy [winfo children .]
1026 # toplevel .f1 -menu .m
1027 # wm geometry .f1 +0+0
1032 # list [info command .f*] [winfo children .]
1034 # eval destroy [winfo children .]
1038 test frame-9.1 {MapFrame procedure} -setup {
1041 toplevel .t -width 100 -height 400
1043 set result [winfo ismapped .t]
1045 lappend result [winfo ismapped .t]
1049 test frame-9.2 {MapFrame procedure} -setup {
1052 toplevel .t -width 100 -height 400
1058 test frame-9.3 {MapFrame procedure, window deleted while mapping} -setup {
1061 toplevel .t2 -width 200 -height 200
1062 wm geometry .t2 +0+0
1063 tkwait visibility .t2
1064 toplevel .t -width 100 -height 400
1066 frame .t2.f -width 50 -height 50
1067 bind .t2.f <Configure> {destroy .t}
1068 pack .t2.f -side top
1076 test frame-10.1 {frame widget vs hidden commands} -setup {
1079 set l [interp hidden]
1083 set res1 [list [winfo children .] [interp hidden]]
1084 set res2 [list {} $l]
1085 expr {$res1 eq $res2}
1089 test frame-11.1 {TkInstallFrameMenu} -setup {
1093 .m1 add cascade -menu .m1.system
1094 menu .m1.system -tearoff 0
1095 .m1.system add command -label foo
1096 toplevel .t -menu .m1
1100 test frame-11.2 {TkInstallFrameMenu - frame renamed} -setup {
1103 catch {rename foo {}}
1105 .m1 add cascade -menu .m1.system
1106 menu .m1.system -tearoff 0
1107 .m1.system add command -label foo
1115 test frame-12.1 {FrameWorldChanged procedure} -setup {
1118 # Test -bd -padx and -pady
1119 frame .f -borderwidth 2 -padx 3 -pady 4
1120 place .f -x 0 -y 0 -width 40 -height 40
1121 pack [frame .f.f] -fill both -expand 1
1123 list [winfo x .f.f] [winfo y .f.f] [winfo width .f.f] [winfo height .f.f]
1126 } -result {5 6 30 28}
1127 test frame-12.2 {FrameWorldChanged procedure} -setup {
1130 # Test all -labelanchor positions
1131 set font {helvetica 12}
1132 labelframe .f -highlightthickness 1 -bd 3 -padx 1 -pady 2 -font $font \
1134 set fh [expr {[font metrics $font -linespace] + 2 - 3}]
1135 set fw [expr {[font measure $font "Mupp"] + 2 - 3}]
1136 if {$fw < 0} {set fw 0}
1137 if {$fh < 0} {set fh 0}
1138 place .f -x 0 -y 0 -width 100 -height 100
1139 pack [frame .f.f] -fill both -expand 1
1142 foreach lp {nw n ne en e es se s sw ws w wn} {
1143 .f configure -labelanchor $lp
1150 n* {incr expy $fh ; incr exph -$fh}
1152 w* {incr expx $fw ; incr expw -$fw}
1155 lappend result [expr {\
1156 [winfo x .f.f] == $expx && [winfo y .f.f] == $expy &&\
1157 [winfo width .f.f] == $expw && [winfo height .f.f] == $exph}]
1162 } -result {1 1 1 1 1 1 1 1 1 1 1 1}
1163 test frame-12.3 {FrameWorldChanged procedure} -setup {
1167 # Check reaction on font change
1168 font create myfont -family courier -size 10
1169 labelframe .f -font myfont -text Mupp
1170 place .f -x 0 -y 0 -width 40 -height 40
1171 pack [frame .f.f] -fill both -expand 1
1172 if {[tk windowingsystem] eq "aqua"} {
1177 set h1 [font metrics myfont -linespace]
1178 set y1 [winfo y .f.f]
1179 font configure myfont -size 20
1180 if {[tk windowingsystem] eq "aqua"} {
1185 set h2 [font metrics myfont -linespace]
1186 set y2 [winfo y .f.f]
1187 expr {($h2 - $h1) - ($y2 - $y1)}
1194 test frame-13.1 {labelframe configuration options} -setup {
1197 labelframe .f -class NewFrame
1201 } -result {-class class Class Labelframe NewFrame}
1202 test frame-13.2 {labelframe configuration options} -setup {
1205 labelframe .f -class NewFrame
1206 .f configure -class Different
1209 } -returnCodes error -result {can't modify -class option after widget is created}
1210 test frame-13.3 {labelframe configuration options} -setup {
1213 labelframe .f -colormap new
1217 test frame-13.4 {labelframe configuration options} -setup {
1220 labelframe .f -visual default
1224 test frame-13.5 {labelframe configuration options} -setup {
1227 labelframe .f -screen bogus
1230 } -returnCodes error -result {unknown option "-screen"}
1231 test frame-13.6 {labelframe configuration options} -setup {
1234 labelframe .f -container true
1238 test frame-13.7 {labelframe configuration options} -setup {
1241 labelframe .f -container true
1242 .f configure -container
1245 } -result {-container container Container 0 1}
1246 test frame-13.8 {labelframe configuration options} -setup {
1249 labelframe .f -container bogus
1252 } -returnCodes error -result {expected boolean value but got "bogus"}
1253 test frame-13.9 {labelframe configuration options} -setup {
1257 .f configure -container 1
1260 } -returnCodes error -result {can't modify -container option after widget is created}
1264 test frame-13.10 {labelframe configuration options} -body {
1265 .f configure -background #ff0000
1266 lindex [.f configure -background] 4
1268 .f configure -background [lindex [.f configure -background] 3]
1270 test frame-13.11 {labelframe configuration options} -body {
1271 .f configure -background non-existent
1272 } -returnCodes error -result {unknown color name "non-existent"}
1273 test frame-13.12 {labelframe configuration options} -body {
1275 lindex [.f configure -bd] 4
1277 .f configure -bd [lindex [.f configure -bd] 3]
1279 test frame-13.13 {labelframe configuration options} -body {
1280 .f configure -bd badValue
1281 } -returnCodes error -result {bad screen distance "badValue"}
1282 test frame-13.14 {labelframe configuration options} -body {
1283 .f configure -bg #00ff00
1284 lindex [.f configure -bg] 4
1286 .f configure -bg [lindex [.f configure -bg] 3]
1288 test frame-13.15 {labelframe configuration options} -body {
1289 .f configure -bg non-existent
1290 } -returnCodes error -result {unknown color name "non-existent"}
1291 test frame-13.16 {labelframe configuration options} -body {
1292 .f configure -borderwidth 1.3
1293 lindex [.f configure -borderwidth] 4
1295 .f configure -borderwidth [lindex [.f configure -borderwidth] 3]
1297 test frame-13.17 {labelframe configuration options} -body {
1298 .f configure -borderwidth badValue
1299 } -returnCodes error -result {bad screen distance "badValue"}
1300 test frame-13.18 {labelframe configuration options} -body {
1301 .f configure -cursor arrow
1302 lindex [.f configure -cursor] 4
1304 .f configure -cursor [lindex [.f configure -cursor] 3]
1306 test frame-13.19 {labelframe configuration options} -body {
1307 .f configure -cursor badValue
1308 } -returnCodes error -result {bad cursor spec "badValue"}
1309 test frame-13.20 {labelframe configuration options} -body {
1310 .f configure -fg #0000ff
1311 lindex [.f configure -fg] 4
1313 .f configure -fg [lindex [.f configure -fg] 3]
1315 test frame-13.21 {labelframe configuration options} -body {
1316 .f configure -fg non-existent
1317 } -returnCodes error -result {unknown color name "non-existent"}
1318 test frame-13.22 {labelframe configuration options} -body {
1319 .f configure -font {courier 8}
1320 lindex [.f configure -font] 4
1322 .f configure -font [lindex [.f configure -font] 3]
1323 } -result {courier 8}
1324 test frame-13.23 {labelframe configuration options} -body {
1325 .f configure -foreground #ff0000
1326 lindex [.f configure -foreground] 4
1328 .f configure -foreground [lindex [.f configure -foreground] 3]
1330 test frame-13.24 {labelframe configuration options} -body {
1331 .f configure -foreground non-existent
1332 } -returnCodes error -result {unknown color name "non-existent"}
1333 test frame-13.25 {labelframe configuration options} -body {
1334 .f configure -height 100
1335 lindex [.f configure -height] 4
1337 .f configure -height [lindex [.f configure -height] 3]
1339 test frame-13.26 {labelframe configuration options} -body {
1340 .f configure -height not_a_number
1341 } -returnCodes error -result {bad screen distance "not_a_number"}
1342 test frame-13.27 {labelframe configuration options} -body {
1343 .f configure -highlightbackground #112233
1344 lindex [.f configure -highlightbackground] 4
1346 .f configure -highlightbackground [lindex [.f configure -highlightbackground] 3]
1348 test frame-13.28 {labelframe configuration options} -body {
1349 .f configure -highlightbackground ugly
1350 } -returnCodes error -result {unknown color name "ugly"}
1351 test frame-13.29 {labelframe configuration options} -body {
1352 .f configure -highlightcolor #123456
1353 lindex [.f configure -highlightcolor] 4
1355 .f configure -highlightcolor [lindex [.f configure -highlightcolor] 3]
1357 test frame-13.30 {labelframe configuration options} -body {
1358 .f configure -highlightcolor non-existent
1359 } -returnCodes error -result {unknown color name "non-existent"}
1360 test frame-13.31 {labelframe configuration options} -body {
1361 .f configure -highlightthickness 6
1362 lindex [.f configure -highlightthickness] 4
1364 .f configure -highlightthickness [lindex [.f configure -highlightthickness] 3]
1366 test frame-13.32 {labelframe configuration options} -body {
1367 .f configure -highlightthickness badValue
1368 } -returnCodes error -result {bad screen distance "badValue"}
1369 test frame-13.33 {labelframe configuration options} -body {
1370 .f configure -labelanchor se
1371 lindex [.f configure -labelanchor] 4
1373 .f configure -labelanchor [lindex [.f configure -labelanchor] 3]
1375 test frame-13.34 {labelframe configuration options} -body {
1376 .f configure -labelanchor badValue
1377 } -returnCodes error -result {bad labelanchor "badValue": must be e, en, es, n, ne, nw, s, se, sw, w, wn, or ws}
1378 test frame-13.35 {labelframe configuration options} -body {
1379 .f configure -padx 3
1380 lindex [.f configure -padx] 4
1382 .f configure -padx [lindex [.f configure -padx] 3]
1384 test frame-13.36 {labelframe configuration options} -body {
1385 .f configure -padx badValue
1386 } -returnCodes error -result {bad screen distance "badValue"}
1387 test frame-13.37 {labelframe configuration options} -body {
1388 .f configure -pady 4
1389 lindex [.f configure -pady] 4
1391 .f configure -pady [lindex [.f configure -pady] 3]
1393 test frame-13.38 {labelframe configuration options} -body {
1394 .f configure -pady badValue
1395 } -returnCodes error -result {bad screen distance "badValue"}
1396 test frame-13.39 {labelframe configuration options} -body {
1397 .f configure -relief ridge
1398 lindex [.f configure -relief] 4
1400 .f configure -relief [lindex [.f configure -relief] 3]
1402 test frame-13.40 {labelframe configuration options} -body {
1403 .f configure -relief badValue
1404 } -returnCodes error -result {bad relief "badValue": must be flat, groove, raised, ridge, solid, or sunken}
1405 test frame-13.41 {labelframe configuration options} -body {
1406 .f configure -takefocus {any string}
1407 lindex [.f configure -takefocus] 4
1409 .f configure -takefocus [lindex [.f configure -takefocus] 3]
1410 } -result {any string}
1411 test frame-13.42 {labelframe configuration options} -body {
1412 .f configure -text {any string}
1413 lindex [.f configure -text] 4
1415 .f configure -text [lindex [.f configure -text] 3]
1416 } -result {any string}
1417 test frame-13.43 {labelframe configuration options} -body {
1418 .f configure -width 32
1419 lindex [.f configure -width] 4
1421 .f configure -width [lindex [.f configure -width] 3]
1423 test frame-13.44 {labelframe configuration options} -body {
1424 .f configure -width badValue
1425 } -returnCodes error -result {bad screen distance "badValue"}
1429 test frame-14.1 {labelframe labelwidget option} -setup {
1432 # Test that label is moved in stacking order
1433 label .l -text Mupp -font {helvetica 8}
1434 labelframe .f -labelwidget .l
1436 frame .f.f -width 50 -height 50
1439 list [winfo children .] [winfo width .f] \
1440 [expr {[winfo height .f] - [winfo height .l]}]
1443 } -result {{.f .l} 54 52}
1444 test frame-14.2 {labelframe labelwidget option} -setup {
1447 # Test the labelframe's reaction if the label is destroyed
1448 label .l -text Aratherlonglabel
1449 labelframe .f -labelwidget .l
1451 label .f.l -text Mupp
1454 set res [list [.f cget -labelwidget]]
1455 lappend res [expr {[winfo width .f] - [winfo width .l]}]
1457 lappend res [.f cget -labelwidget]
1459 lappend res [expr {[winfo width .f] - [winfo width .f.l]}]
1462 } -result {.l 12 {} 4}
1463 test frame-14.3 {labelframe labelwidget option} -setup {
1466 # Test the labelframe's reaction if the label is stolen
1467 label .l -text Aratherlonglabel
1468 labelframe .f -labelwidget .l
1470 label .f.l -text Mupp
1473 set res [list [.f cget -labelwidget]]
1474 lappend res [expr {[winfo width .f] - [winfo width .l]}]
1476 lappend res [.f cget -labelwidget]
1478 lappend res [expr {[winfo width .f] - [winfo width .f.l]}]
1481 } -result {.l 12 {} 4}
1482 test frame-14.4 {labelframe labelwidget option} -setup {
1485 # Test the label's reaction if the labelframe is destroyed
1487 labelframe .f -labelwidget .l
1490 set res [list [winfo manager .l]]
1492 lappend res [winfo manager .l]
1495 } -result {labelframe {}}
1496 test frame-14.5 {labelframe labelwidget option} -setup {
1499 # Test that the labelframe reacts on changes in label
1500 label .l -text Aratherlonglabel
1501 labelframe .f -labelwidget .l
1503 label .f.l -text Mupp
1506 set first [winfo width .f]
1507 set res [expr {[winfo width .f] - [winfo width .l]}]
1508 .l configure -text Shorter
1510 lappend res [expr {[winfo width .f] - [winfo width .l]}]
1511 lappend res [expr {[winfo width .f] < $first}]
1512 .l configure -text Alotlongerthananytimebefore
1514 lappend res [expr {[winfo width .f] - [winfo width .l]}]
1515 lappend res [expr {[winfo width .f] > $first}]
1518 } -result {12 12 1 12 1}
1519 test frame-14.6 {labelframe labelwidget option} -setup {
1522 # Destroying a labelframe with a child label caused a crash
1523 # when not handling mapping of the label correctly.
1524 # This test does not test anything directly, it's just ment
1525 # to catch if the same mistake is made again.
1528 label .f.l -text Mupp
1529 .f configure -labelwidget .f.l
1536 rename colorsFree {}