For instance, it can be used for :
Creation of the screens
The creation of one screen is made easier by the use of functions. One
function creates automatically the title, the description zone and the
zone containing the fields where the user interact with the wizard.
Actions that take place when going from one screen to an other
Two functions are called, the first when a screen is displayed and the other one when one lives the current screen. These functions have both among their parameters the index of the current screen . The function called when we leave one screen turns over a booleen, which indicates if it is allowed going to the next screen. In fact, the developer will need to verify if the user correctly filled the fields of the interface, and to act in consequense (Appearance of a Message Box).
In algorithmic language, a wizard can be described as follow :
title = "pseudo-code "
create screen 0 " Introductive screen " " Description of the first screen " |
... |
create screen N " Screen N title " " Description of screen N " |
create two Widgets 'input' and 'list' (for example) |
... |
create the last screen "Apply " " User's inputs " |
create apply button callback apply |
InputScreen (N) |
switch (n) { |
case ... |
case N: if Widget 'input' is empty then message box "You must fill this field " return false |
if no choice has been done in Widget 'list' then message box " You must choose one item " return false |
} |
Apply { if Action = Ok then message box " Good ;-)" |
else message box " Sorry, you loose :-( " |
exit |
} |
In tcl-tk
One has two global variables: nbtotalecran the total number of screen and nb_screen which indicates the current screen.
One will display the first screen with the packer ( pack .f0 ).
For the Previous and Next buttons, one associates 2 callbacks :
These two functions increase or decrease the global variable nb_screen, mask the old screen and display the new screen.
Tcl-Tk has a very interesting feature : in the language it preserves the names of the screens and of the variables; they can be called as in an array, with a number. Thus, it suffices to create all your dialog screens for the Wizard with a path .f$screen_number: function creationscreennb
You can mask or display them with the command:
At each screen change, two functions are called:
Function | Parameter |
InputScreen | Number of the new screen |
OutputScreen | Number of the old screen |
Most of the work done by the wizard is carried out in these two functions :
proc InputScreen { N } { switch -- $$n {
0 { puts " InputScreen 0 " }1 { puts " InputScreen 1 " }
} }
proc OutputScreen { N } { switch -- $$n {
0 { puts " OutputScreen 0 " }1 { puts " OutputScreen 1 " }
} }
As in Tcl-tk, each dialog screen will be created with a number
/ * Wizard global variables * /
int current_screen = 0;
int index_screen=0;
The MakeAssistantScreen function will create a form, a label
title, and a descriptive text.
Then it will be enough to create Widgets and to call AddWidget.
The remainder is automatic.
At each screen change, two functions are called :
Function | Parameter |
InputScreen | Number of the new screen |
OutputScreen | Number of the old screen |
These two functions make it possible to influate the wizard while it is in use. The InputScreen function is called when one enter in a new screen. Conversely, the OutputScreen function is called when one leaves the current screen, and return a boolean which indicates if this change is allowed. They have both among their parameters, the number of the screen concerned with the action. It will be enough for you to make a switch ... case on this number and to act in consequence.
Exemple:
InputScreen in C
switch (n){ case 2 :
sprintf(homedir,"/home/%s",username);
SetStringEntry(Whomedir,homedir);}break;
...
OutScreen in C:
switch (n){ case 0:
strcpy(username,GetStringEntry(Wnomuser));}if (strchr(username,' ')!=NULL) {
printf("A username cannot contains the space char");}GetYesNo("A username cannot contains space char");
return(FALSE);
Here FALSE indicates that one does not want to change screen since an error occurs....
Make a Wizard
You can help me and the Wizard project, send me :
Thank you