Wizard

A wizard is an interactive help utility that guides the user through a potentially complex task, such as configuring a PPP driver to work with a new modem. Wizards are often implemented as a sequence of dialog boxes which the user can move forwards and backwards through, filling in the details required. The implication is that the expertise of a human wizard in one of the above senses is encapsulated in the software wizard, allowing the average user to perform expertly.

Tcl Software for creating Wizard functionality


MJ For a very basic wizard which leaves the creation of the separate pages up to you but will provide the navigation, the following can serve as a start:

 package require Tk
 # requires 8.5 because of use of {*}
 package require Tcl 8.5

 proc wizard {toplevel pages} {
    toplevel $toplevel
    set page_list {}

    for {set i 1} {$i <= $pages} {incr i} {
        set finish {}
        set page $toplevel.p$i
        frame $page
        frame $page.page
        lappend page_list $page.page
        button $page.p -text Previous... -command [list move $page.page -1]
        button $page.n -text Next... -command [list move $page.page 1]
        if {$i == 1} {
            $page.p configure -state disabled
        }
        if {$i == $pages} {
            $page.n configure -state disabled
            button $page.f -text Finish -command $toplevel.finish           
            set finish $page.f
        }
        grid $page.page  -columnspan 4  -sticky nsew
        grid $page.p $page.n {*}$finish
        grid columnconfigure $page 3 -weight 1
        grid rowconfigure $page 0 -weight 1
    }
    return $page_list
 }



 proc move {page {offset 0}} {
    set page [winfo parent $page]
    regexp {^(.*\.p)([0-9]+)$} $page -> root number
    pack forget $page
    set newnumber [expr {$number + $offset}]
    set newpage "$root$newnumber"
    pack $newpage -fill both -expand 1
    wm title [winfo toplevel $newpage] "Page $newnumber"
 }

 set pages [wizard .wzrd 10]

 # finish button will call <toplevel>.finish
 proc .wzrd.finish {args} {
    # wzrd is finished
    puts "finished"
    destroy .wzrd
 }

 # set up pages
 # every page returned by [wizard ...] is a frame where you can construct your page
 foreach page $pages {
    text $page.t
    pack $page.t -fill both -expand 1
 }

 # show the first page
 move [lindex $pages 0]
 wm withdraw .
 catch {console show}