Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

After reviewing and running your code, and having read a zillion of theses posts now, I knew that a more learned Monk would suggest using one of the CPAN XML parsers. Thanks stefbz. I have not gotten into XML at all yet.

I do think that you should be using a dialog(modal) rather than individual controls. I would start with the wxSingleChoiceDialog and use it to get my application logic correct. Build and popup the dialog, extract your answer, destroy the popup, then repeat for all of your questions. Then if you still want a different look and feel you could implement a custom dialog like the wxSingleChoiceDialog, but using radio boxes instead of a list. See CppTrial-pg225.pl for the wxSingleChoiceDialog example and CppTrial-pg245.pl for the PersonalRecordDialog custom dialog example.

The next more complicated option would be to create a wxWizard. Unfortunately I haven't yet implemented the wxWizard example from the "wxBook" in my github examples.

See also the wxDemo wxWizard and wxSingleChoiceDialog examples. I run Citrus Perl 5.16 and on my system these can be found at home/CitrusPerl/perl/vendor/bin/wxperl_demo.pl. Look under the Managed Windows and Dialogs sections.

Please repost your working application to add to the example base.

Update1:See if the following code can be integrated with your XML code.

#!/usr/bin/perl # Highly Modified CppTrial-pg225.pl in Answer to Perl Monks question # Cross-Platform GUI Programming with wxWidgets - Smart, Hock, & Csomo +r # C++ Example from pg 225 - Single Choice Dialog # Ported to wxPerl by James M. Lynes Jr. - Last Modified 1/5/2013 use 5.010; use strict; use warnings; use Wx qw(:everything); use Wx::Event qw(EVT_PAINT); # create the WxApplication my $app = Wx::SimpleApp->new; my $frame = Wx::Frame->new(undef, -1, 'Company Survey', wxDefaultPosit +ion, wxDefaultSize); # Parse your XML into $title, $question, & @choices and pass into subr +outine, loop for all questions myStdDialogs1($frame); # Duplicate calls to sim +ulate a loop myStdDialogs2($frame); # Duplicate calls to sim +ulate a loop $frame->Show; $app->MainLoop; sub myStdDialogs1 { my ( $self ) = @_; my $title = "Survey question: TNHSCS010001"; # Hard cod +ed for example...pass in, in live code my $question = "Jenkins is primiary used of ........?"; my @choices = ("1 Nightly Builds", "3 CI Builds", "4 Report Generation", "1 All the above"); my $singleChoiceDialog = Wx::SingleChoiceDialog->new($self, $quest +ion, $title, \@choices); if( $singleChoiceDialog->ShowModal() == wxID_OK) { Wx::MessageBox($singleChoiceDialog->GetStringSelection(), "Selected Answer", wxOK | wxICON_INFORMATION, $self); } $singleChoiceDialog->Destroy; } sub myStdDialogs2 { my ( $self ) = @_; my $title = "Survey question: TNHSCS010001"; # Hard cod +ed for example...pass in, in live code my $question = "Jenkins is primiary used of ........?"; my @choices = ("1 Nightly Builds", "3 CI Builds", "4 Report Generation", "1 All the above"); my $singleChoiceDialog = Wx::SingleChoiceDialog->new($self, $quest +ion, $title, \@choices); if( $singleChoiceDialog->ShowModal() == wxID_OK) { Wx::MessageBox($singleChoiceDialog->GetStringSelection(), "Selected Answer", wxOK | wxICON_INFORMATION, $self); } $singleChoiceDialog->Destroy; }

Update2:Just for completeness a wxWizard example follows.

#!/usr/bin/perl # wxWizard.pl # Adapted from wxperl_demo.pl from the wxPerl distribution # James M. Lynes Jr. - Last Modified 1/6/2013 use 5.010; use strict; use warnings; use Wx qw(:everything); use Wx::Event qw(EVT_WIZARD_PAGE_CHANGED EVT_BUTTON EVT_WIZARD_FINISHE +D EVT_WIZARD_CANCEL); # create the WxApplication my $app = Wx::SimpleApp->new; my $frame = Wx::Frame->new( undef, -1,'wxWizard.pl', wxDefaultPosi +tion, wxDefaultSize ); my $panel = Wx::Panel->new($frame, -1, wxDefaultPosition, wxDefaul +tSize); Wx::StaticText->new($panel, -1, "WxWizard Sample Program", Wx::Poi +nt->new(100,100), Wx::Size->new(200,200), wxALIGN_CENTER); my $button = Wx::Button->new( $panel, -1, "Start Wizard", Wx::Poin +t->new(150, 225), wxDefaultSize ); Wx::InitAllImageHandlers(); my $bmp = Wx::Bitmap->new("logo.png", wxBITMAP_TYPE_PNG); my $wizard = Wx::Wizard->new( $panel, -1, "Wizard Example", $bmp ) +; # first page my $page1 = Wx::WizardPageSimple->new( $wizard ); Wx::TextCtrl->new( $page1, -1, "First page", wxDefaultPosition, Wx +::Size->new(200,25) ); # second page my $page2 = Wx::WizardPageSimple->new( $wizard ); Wx::TextCtrl->new( $page2, -1, "Second page", wxDefaultPosition, W +x::Size->new(200,25) ); # third page my $page3 = Wx::WizardPageSimple->new( $wizard ); Wx::TextCtrl->new( $page3, -1, "Third page", wxDefaultPosition, Wx +::Size->new(200,25) ); # fourth page my $page4 = Wx::WizardPageSimple->new( $wizard ); Wx::TextCtrl->new( $page4, -1, "Fourth page", wxDefaultPosition, W +x::Size->new(200,25) ); Wx::WizardPageSimple::Chain( $page1, $page2 ); Wx::WizardPageSimple::Chain( $page2, $page3 ); Wx::WizardPageSimple::Chain( $page3, $page4 ); EVT_BUTTON( $panel, $button, sub {$wizard->RunWizard( $page1 ); } +); EVT_WIZARD_CANCEL( $panel, $wizard, sub {Wx::Wizard->Destroy();} ) +; EVT_WIZARD_FINISHED($panel, $wizard, sub { Wx::Wizard->Destroy(); +} ); # Testing Messages comment out matching event above # EVT_WIZARD_FINISHED($panel, $wizard, sub { Wx::LogMessage( "Wizar +d Canceled" ); } ); # EVT_WIZARD_PAGE_CHANGED( $panel, $wizard, sub {Wx::LogMessage( "W +izard page changed" ); } ); # EVT_WIZARD_CANCEL( $panel, $wizard, sub {Wx::LogMessage( "Wizard +Canceled" ); } ); $frame->Show; $app->MainLoop;

James

There's never enough time to do it right, but always enough time to do it over...


In reply to Re: WxPerl Next button by jmlynesjr
in thread WxPerl Next button by saran73

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (16)
    As of 2014-10-21 13:38 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (103 votes), past polls