[Arjen Markus] The script below is an experiment in a more sophisticated use of the text widget than what I usually do. It is also a joke - with two Tcl events this year, 2002, why not use Tcl/T for a presentation? Note that the current version is far from completed. But you will get an idea anyway. ---- # present.tcl -- # # Script to show slides, using a Wiki-like format for entering the text # # Version information: # version 0.1: initial implementation, april 2002 # buildSlide -- # Build up a new slide # # Arguments: # contents List containing the text to be shown # # Result: # None # # Side effects: # Text window is filled with the new text # proc buildSlide { contents } { global textwindow $textwindow delete 0.0 end foreach {tag_text} $contents { foreach {tag text} $tag_text {break} $textwindow insert end "$text\n" $tag } } # displayNewSlide -- # Move to a new slide (depending on the direction: next, previous, ...) # # Arguments: # dir Direction to take # # Result: # None # # Side effects: # Text window shows the new slide # proc displayNewSlide { dir } { global current_slide global number_slides global slide_contents switch -- $dir { "1" { incr current_slide } "-1" { incr current_slide -1 } "begin" { set current_slide 0 } "end" { set current_slide $number_slides } default { return } } if { $current_slide < 0 } { set current_slide 0 } if { $current_slide >= $number_slides } { set current_slide [expr {$number_slides-1}] } buildSlide $slide_contents($current_slide) } # mainWindow -- # Set up the main (text) window and bindings # # Arguments: # None # # Result: # None # # Side effect: # Main window, tags and bindings defined # proc mainWindow { } { global textwindow set textwindow ".textwindow" text $textwindow -width 70 -height 25 pack $textwindow -fill both font create Title -family Helvetica -size 24 -weight bold font create Text -family Helvetica -size 16 -weight normal font create Code -family Courier -size 14 -weight normal $textwindow tag configure title -justify center -font Title $textwindow tag configure text -justify left -font Text $textwindow tag configure code -justify left -font Code bind $textwindow {displayNewSlide 1} bind $textwindow {displayNewSlide 1} bind $textwindow {displayNewSlide -1} bind $textwindow {displayNewSlide begin} bind $textwindow {displayNewSlide end} } # # Main code # mainWindow global slide_contents global current_slide global number_slides set slide_contents(0) { {title {Aha, my title}} {text {Some text}} {text {Again a line}} {code {Display code}} } set slide_contents(1) { {title {---, my title}} {text {Some text}} {text {Again a line}} } set slide_contents(2) { {title {The end}} {text {}} {text {}} {text { -- End --}} } set current_slide 0 set number_slides 3 displayNewSlide begin # # Take the focus - in this order! # focus $::textwindow focus -force . ---- A script that also exploits the possibilities of the simple Wiki format: [htext] ---- [Arts and crafts of Tcl-Tk programming]