package require tk package require tcltest 2.2 namespace import -force tcltest::* loadTestedCommands test labelframe-1.0 "Setup" -body { pack [ttk::labelframe .lf] -expand true -fill both } test labelframe-2.1 "Can't use indirect descendant as labelwidget" -body { ttk::frame .lf.t ttk::checkbutton .lf.t.cb .lf configure -labelwidget .lf.t.cb } -returnCodes error -result "can't *" -match glob \ -cleanup { destroy .lf.t } ; test labelframe-2.2 "Can't use toplevel as labelwidget" -body { toplevel .lf.t .lf configure -labelwidget .lf.t } -returnCodes error -result "can't *" -match glob \ -cleanup { destroy .lf.t } ; test labelframe-2.3 "Can't use non-windows as -labelwidget" -body { .lf configure -labelwidget BogusWindowName } -returnCodes error -result {bad window path name "BogusWindowName"} test labelframe-2.4 "Can't use nonexistent-windows as -labelwidget" -body { .lf configure -labelwidget .nosuchwindow } -returnCodes error -result {bad window path name ".nosuchwindow"} ### # See also series labelframe-4.x # test labelframe-3.1 "Add child content" -body { checkbutton .lf.cb -text "abcde" .lf configure -labelwidget .lf.cb list [update; winfo viewable .lf.cb] [winfo manager .lf.cb] } -result [list 1 labelframe] test labelframe-3.2 "Remove child content" -body { .lf configure -labelwidget {} list [update; winfo viewable .lf.cb] [winfo manager .lf.cb] } -result [list 0 {}] test labelframe-3.3 "Re-add child content" -body { .lf configure -labelwidget .lf.cb list [update; winfo viewable .lf.cb] [winfo manager .lf.cb] } -result [list 1 labelframe] test labelframe-3.4 "Re-manage child content" -body { pack .lf.cb -side right list [update; winfo viewable .lf.cb] [winfo manager .lf.cb] [.lf cget -labelwidget] } -result [list 1 pack {}] test labelframe-3.5 "Re-add child content" -body { .lf configure -labelwidget .lf.cb list [update; winfo viewable .lf.cb] [winfo manager .lf.cb] } -result [list 1 labelframe] test labelframe-3.6 "Destroy child content" -body { destroy .lf.cb .lf cget -labelwidget } -result {} ### # Re-run series labelframe-3.x with nonchild content. # # @@@ ODDITY, 14 Nov 2005: # @@@ labelframe-4.1 fails if .cb is a [checkbutton], # @@@ but seems to succeed if it's some other widget class. # @@@ I suspect a race condition; unable to track it down ATM. # # @@@ FOLLOWUP: This *may* have been caused by a bug in ManagerIdleProc # @@@ (see manager.c r1.11). There's still probably a race condition in here. # test labelframe-4.1 "Add nonchild content" -body { checkbutton .cb -text "abcde" .lf configure -labelwidget .cb update list [winfo ismapped .cb] [winfo viewable .cb] [winfo manager .cb] } -result [list 1 1 labelframe] test labelframe-4.2 "Remove nonchild content" -body { .lf configure -labelwidget {} update; list [winfo ismapped .cb] [winfo viewable .cb] [winfo manager .cb] } -result [list 0 0 {}] test labelframe-4.3 "Re-add nonchild content" -body { .lf configure -labelwidget .cb list [update; winfo viewable .cb] [winfo manager .cb] } -result [list 1 labelframe] test labelframe-4.4 "Re-manage nonchild content" -body { pack .cb -side right list [update; winfo viewable .cb] \ [winfo manager .cb] \ [.lf cget -labelwidget] } -result [list 1 pack {}] test labelframe-4.5 "Re-add nonchild content" -body { .lf configure -labelwidget .cb list [update; winfo viewable .cb] \ [winfo manager .cb] \ [.lf cget -labelwidget] } -result [list 1 labelframe .cb] test labelframe-4.6 "Destroy nonchild content" -body { destroy .cb .lf cget -labelwidget } -result {} test labelframe-5.0 "Cleanup" -body { destroy .lf } # 1342876 -- labelframe should raise sibling -labelwidget above self. # test labelframe-6.1 "Stacking order" -body { toplevel .t pack [ttk::checkbutton .t.x1] pack [ttk::labelframe .t.lf -labelwidget [ttk::label .t.lb]] pack [ttk::checkbutton .t.x2] winfo children .t } -cleanup { destroy .t } -result [list .t.x1 .t.lf .t.lb .t.x2] test labelframe-7.1 "style command" -body { ttk::labelframe .w list [.w cget -style] [.w style] [winfo class .w] } -cleanup { destroy .w } -result {{} TLabelframe TLabelframe} test labelframe-7.2 "style command" -body { ttk::style configure customStyle.TLabelframe ttk::labelframe .w -style customStyle.TLabelframe list [.w cget -style] [.w style] [winfo class .w] } -cleanup { destroy .w } -result {customStyle.TLabelframe customStyle.TLabelframe TLabelframe} tcltest::cleanupTests