Tcl Software for creating Wizard functionality edit
- add wizard
- TkWizard
- SC [2005/02/22] -- snitwiz is my own wizard package based on snit.
- VS [2007/10/29] Also using BWidget::PagesManager.
- WJG (21/10/10) The gnocl::assistant widget provides full wizard functionality. Check out the wiki page for more details.
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}