Fixes for componentized Pagedform
[tcl-tlc.git] / examples / wizard.tcl
blobd183f52353db229f6e6c1f24b0f4b4b7fb7001ad
1 #!/usr/bin/env tclsh8.5
3 # vim: ft=tcl foldmethod=marker foldmarker=<<<,>>> ts=4 shiftwidth=4
5 package require TLC 0.90.0
7 source "boilerplate.tcl"
9 Wizard .wizard -showhelp 1 -startpage start -routing {
10 start { #<<<
11 Next {
12 {$dat(usefoo)} get_foo
13 default get_bar
16 #>>>
17 get_foo { #<<<
18 Back start
19 Next get_bar
21 #>>>
22 get_bar { #<<<
23 Back {
24 {$dat(usefoo)} get_foo
25 default start
27 Next get_baz
29 #>>>
30 get_baz { #<<<
31 Skip_if {$dat(usefoo)}
32 Back get_bar
33 Next review
35 #>>>
36 review { #<<<
37 Back get_bar
38 Finish {}
40 #>>>
41 } -pages {
42 start { #<<<
43 title "Hello, Wizard"
44 type form
45 schema {
46 _layout {row_args_sticky -resize none}
47 _layout {col_args_sticky -resize none}
48 "Foo?" {usefoo radiogroup -choices {
49 "Use Foo" 1
50 "Don't Use foo" 0
54 _defaults {
55 usefoo 1
58 _validation_not_blank {
59 "%1 must be filled in"
60 "Foo?" usefoo
63 help {
64 <h2>This is the startpage of the wizard</h2>
66 <p>Do you want some foo? If you don't, you'll need to provide
67 baz later on</p>
70 #>>>
71 get_foo { #<<<
72 title "Get Foo"
73 type form
74 schema {
75 _layout {row_args_sticky -resize none}
76 _layout {col_args_sticky -resize none}
77 "Foo" {foo entry}
79 _validation_not_blank {
80 "%1 must be filled in"
81 "Foo" foo
84 help {
85 Please provide the Foo.
88 #>>>
89 get_bar { #<<<
90 type form
91 schema {
92 _layout {row_args_sticky -resize none}
93 _layout {col_args_sticky -resize none}
94 "Foo" {foo label}
95 "Bar" {bar entry}
97 _validation_not_blank {
98 "%1 must be filled in"
99 "Bar" bar
102 _validation {
103 {[info exists dat(usefoo)] && !$dat(usefoo) || [string first $dat(foo) $dat(bar)] > -1}
104 "If use choose to use foo, bar must contain it"
105 {bar}
109 #>>>
110 get_baz { #<<<
111 type form
112 schema {
113 _layout {row_args_sticky -resize none}
114 _layout {col_args_sticky -resize none}
115 "Baz" {baz entry}
117 _validation_not_blank {
118 "%1 must be filled in"
119 "Baz" baz
123 #>>>
124 review { #<<<
125 #type form
126 #schema {
127 # _layout {row_args_sticky -resize none}
128 # _layout {col_args_sticky -resize none}
129 # "Foo" {foo label}
130 # "Bar" {bar label}
132 type html
133 html {
134 <table>
135 <tr><td>Foo</td><td>%foo%</td></tr>
136 <tr><td>Bar</td><td>%bar%</td></tr>
137 <tr class="optional"><td>Bar</td><td>%bar%</td></tr>
138 </table>
140 styles {
141 .optional TD {
142 font-style: italic;
143 color: #303030;
147 #>>>
148 } -oncancel {
149 exit 1
152 blt::table . \
153 .wizard 1,1 -fill both
155 wm geometry . "600x320"
157 .wizard waitfor finished
159 array set dat [.wizard get_data]
160 delete object .wizard
162 puts "Got:"
163 parray dat
165 exit