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


In reply to Simple wxWizard application by TGI

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.