Tk Source Code

Artifact [3c9cf11a]
Login

Artifact 3c9cf11ab75aa95864da8c1edfe6f3bb52ddd537:

Attachment "snippet.tcl" to ticket [3166688f] added by zoro2 2011-01-28 01:56:19.
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
pack .main.page2.text -fill both -expand 1

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

# afterwards, clicking on "Page 2" without any further mouse movement
# there is noticable difference in refresh time between Carbon and Cocoa