TGI has asked for the wisdom of the Perl Monks concerning the following question:
I am putting together a very simple wizard application using wxPerl. For obvious reasons I am planning to use the wxWizard class. While the example in wxperl_demo is great for showing how to use the wxWizard class inside a larger application, it does not give much guidance for setting up a very simple app.
All I want to do is create and run a wizard to collect some survey info. Any processing will be done as the user steps through the pages. The problem is, how do I start the wizard?
I've come up with two approaches that seem to "work" but both feel dodgy. I can get the wizard to run by putting the RunWizard call into the application's OnInit handler. I've also tried removing the call to start the MainLoop, and just called RunWizard() instead.
use strict; use warnings; use Wx; package WizTest; use base qw(Wx::App); # Inherit from Wx::App use Wx::Event qw(EVT_WIZARD_FINISHED); sub OnInit { my $self = shift; my $wizard = Wx::Wizard->new( undef, -1, "Wizard test" ); # first page my $page1 = Wx::WizardPageSimple->new( $wizard ); Wx::TextCtrl->new( $page1, -1, "First page" ); # second page my $page2 = Wx::WizardPageSimple->new( $wizard ); Wx::TextCtrl->new( $page2, -1, "Second page" ); Wx::WizardPageSimple::Chain( $page1, $page2 ); EVT_WIZARD_FINISHED( $self, $wizard, sub { warn "Wizard finished\n"; } ); # Preempt everything and run the wizard now. # $wizard->RunWizard( $page1 ); $self->{wizard} = $wizard; $self->{start_page} = $page1; } package main; my $app = WizTest->new(); # New HelloWorld application # Note that I don't start the MainLoop $app->{wizard}->RunWizard( $app->{start_page} );
Neither approach seems right. My intuition tells me that I really ought to be running the main loop and then triggering the wizard somehow.
Anyone have any suggestions on how to start my wizard up?
TGI says moo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simple wxWizard application
by igelkott (Priest) on Nov 06, 2007 at 08:26 UTC | |
by TGI (Parson) on Nov 06, 2007 at 16:52 UTC | |
|
Re: Simple wxWizard application
by Anonymous Monk on Nov 06, 2007 at 10:11 UTC |