Tk Source Code

Artifact [9d4d0cda]
Login

Artifact 9d4d0cdad05b3bacabe150f31212a697e40e5056:

Attachment "gui-frames-noupdate.tcl" to ticket [3166688f] added by zoro2 2011-02-23 15:38:16.
package require Tk

ttk::frame .main
ttk::frame .main.page1

ttk::label .main.page1.label1 -text "Some label 1 / 1"
ttk::label .main.page1.label2 -text "Some label 1 / 2"
pack .main.page1.label1 -fill x
pack .main.page1.label2 -fill x

ttk::frame .main.page2
text .main.page2.text -height 2
pack .main.page2.text -fill x
set p .main.page2.f
for {set i 0} {$i < 50} {incr i} {
    frame $p -pady 2 -background [format "#%06x" [expr {int(rand()*16777215.0)}]]
    pack $p -fill both -expand 1
    set p $p.f
}


ttk::frame .buttons
ttk::button .buttons.p1 -text "Page 1" -command {show 1}
ttk::button .buttons.p2 -text "Page 2" -command {show 2}
pack .buttons.p1 .buttons.p2 -side left  -fill both -expand 1

pack .main -fill both -expand 1
pack .buttons -fill x

pack propagate .main 0
wm geometry . 500x300

proc show {p} {
    foreach page {1 2} {
        if {$page != $p} {
            catch {pack forget .main.page$page}
        }
    }
    pack .main.page$p -fill both -expand 1
}

show 1