next up previous
Next: About this document Up: Tk: A User Previous: Hello World in

An Extended Tk Example

    #!/software/tk/bin/wish -f
    wm title . $argv0
(Definition of the power procedure goes here)
    set base 1; set p 1; set result 1
    entry .base -width 6 -relief sunken -textvariable base
    label .label1 -text "^"
    entry .p -width 6 -relief sunken -textvariable p
    label .label2 -text "="
    label .result -textvariable result
    pack .base .label1 .p .label2 .result -side left -padx 1m -pady 2m
    bind .base <Return> {set result [power $base $p]}
    bind .p <Return> {set result [power $base $p]}

CS488/688: Introduction to Interactive Computer Graphics
University of Waterloo
Computer Graphics Lab