perlquestion
perlNoob
Hello monks,
<p>
Basically I want to do something similar to a wizard, as in have several sequential windows stepping through. I can't seem to be able to get my 'next' button working properly. What I want it to do is call a sub, which would be the code of the next window, or a .pl file which contains the code for the next window and then exit the current one.<br>
To help you understand here is an example of something similar to what I want to do (with the same problem I have, but I did it to make it easier to locate the problem):<br>
<code>
use Tk;
my $mw = MainWindow->new;
$mw->title("Window1");
$mw->MainWindow->Frame(-relief=>'groove');
$mw->minsize(600,300);
my $welcome = $mw-> Message(-font => '16', -text =>"Hello World!")->pack(-side => 'left', -anchor=>'ne');
my $bf = $mw-> Frame(-pady => '5')->pack(-side => 'bottom', -anchor=>'se');
my $cancel = $bf -> Button(-relief=> 'raised', -borderwidth => '2', -text => "Cancel", -command => sub { exit })->pack(-side => 'right',-padx => '20');
my $next = $bf -> Button(-relief=> 'raised', -borderwidth => '2', -text => "Next", -command => sub { \&rep2 , exit})->pack(-side => 'right');
my $back = $bf -> Button(-state => 'disabled', -relief=> 'raised', -borderwidth => '2', -text => "Back")->pack(-side => 'right');
MainLoop;
sub rep2 {
my $rep2 = MainWindow->new;
$rep2->tittle("Window2");
$rep2->minsize(600,300);
my $bf = $rep2-> Frame(-pady => '5')->pack(-side => 'bottom', -anchor=>'se');
my $msg = $rep2-> Message(-text => "This is the second window.")->pack();
my $finish = $bf -> Button(-relief=> 'raised', -borderwidth => '2', -text => "Finish", -command => sub{exit})->pack(-side => 'right');
MainLoop;
}
</code>
This doesn't seem to work and in the -command of the "next" button if I put: -command => \&rep2 instead it creates new random empty windows and doesn't recognize the tittle or minimum size set for it.Could you please help me?<p> Thank you for your efforts :)