Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Hi James, Thanks for your reply. I did use few of the examples from the github (very useful and thanks for sharing it). Here is the code: (input is at the end of the file)
use strict; use warnings; use Wx; use Wx::Event qw( EVT_BUTTON ); use Wx qw[:everything]; use base qw/Wx::Frame/; # Inherit from Wx::Frame our %panel; my $selectedChapter; Main( @ARGV ); exit( 0 ); sub Main { my $app = Wx::SimpleApp->new; my $frame = Wx::Frame->new( undef, -1, "Test window", [ 100, 100 ], [ 800, 600 ], Wx::wxDEFAULT_FRAME_STYLE()|Wx::wxTAB_TRAVERSAL() ); MakeChaptersPanel( $frame ); $frame->SetSizer( Wx::BoxSizer->new( Wx::wxVERTICAL() ) ); $frame->GetSizer->Add( $panel{first}, 1, Wx::wxEXPAND() ); $frame->Show(1); $app->SetTopWindow($frame); $app->MainLoop; } ## end sub Main sub MakeChaptersPanel { my( $frame ) = @_; $panel{'first'} = Wx::Panel->new( $frame, -1, [ -1, -1 ], [ -1, -1], ); Wx::StaticText->new( $panel{'first'}, 1, "Answer Verification App", [50, 50] ); my $SHOWQUESTION_BTNID = 1; my $showQuestions = Wx::Button->new( $panel{'first'}, $SHOWQUESTION_BTNID, "Show Questions", [150,300] ); my %chapters; my $data_pos = tell DATA; # save the position while (<DATA>) { if ( m@<questionId>.*?(\d\d)(\d{4})</questionId>@) { $chapters{$1}++; } } seek DATA, $data_pos, 0; my @chapters; foreach my $chapter (keys %chapters) { push(@chapters,$chapter); } my $CHAPTER_RADIOBOX = 2; my $selectChapter = Wx::RadioBox->new($panel{'first'}, $ CHAPTER_RADIOBOX, "Select the Chapter", Wx::Point->new(100,100), wxDefaultSize, \@chap +ters, 1, wxRA_SPECIFY_COLS); $selectChapter->SetSelection(1); Wx::Event::EVT_BUTTON( $frame, $showQuestions, sub{\&ShowQuestions(@_, $selectChapter->GetStringSelection())}); return; } ## end sub MakePanels sub MakeQuestionsPanel { my( $frame ) = @_; $panel{'second'} = Wx::Panel->new( $frame, -1, [ -1, -1 ], [ -1, -1 ], ); $panel{'second'}->Hide(); my $NEXTQUESTION_BTNID = 2; my $nextQuestionbtn = Wx::Button->new( $panel{'second'}, $NEXTQUESTION_BTNID, "Next Questions", [150,300] ); my $insideQuestion = 0; my @answerChoices; my $correctAnswer; my $weightage; my $QUESTIONS_RADIOBOX = 3; while (<DATA>) { if ( m@<Question>@ ) { $insideQuestion = 1; print $_; next; } if ( m@</Question>@ ) { $insideQuestion = 0; my $questionChoices = Wx::RadioBox->new($panel{'second'}, $QUESTIONS_RADIOBOX, "Answer Choices +", Wx::Point->new(100,100), wxDefaultSize, \@answerChoices, 1, wxRA_SPECIFY_COLS); $questionChoices->SetStringSelection($correctAnswer); last; } if ( $insideQuestion ) { if ( m@<questionId>.*?(\d\d)(\d{4})</questionId>@) { if ( $1 != $selectedChapter) { $insideQuestion = 0; next; } } if ( m@<question>(.*?)</question>@ ) { print "$1\n"; my $questionText = Wx::StaticText->new( $panel{'secon +d'}, 1, "$1", [50, 70] ); } elsif ( m@<Answer\d>(.*?)</Answer\d>@ ) { push(@answerChoices,$1); } elsif ( m@<CorrectAnswer>(.*?)</CorrectAnswer>@ ) { $correctAnswer = $1; } elsif ( m@<weightage>(.*?)</weightage>@ ) { $weightage = $1; } print "$_"; } } return; } sub ShowQuestions { my ( $frame, $event, $mySelectedChapter ) = @_; my $button = $event->GetEventObject; my $label = $button->GetLabel(); $selectedChapter = $mySelectedChapter; $frame->SetTitle("Chapter " . $selectedChapter); MakeQuestionsPanel( $frame ); $panel{first}->Hide(); $panel{second}->Show(); $frame->GetSizer->Add( $panel{second}, 1, Wx::wxEXPAND() ); $frame->GetSizer->Layout(); } __DATA__ <Question> <questionId>TNHSCS010001</questionId> <question>Jenkins is primiary used of ........</question> <Answer1> Nightly Builds </Answer1> <Answer3> CI Builds </Answer3> <Answer4> Report Generation </Answer4> <Answer1> All the above </Answer1> <CorrectAnswer> CI Builds </CorrectAnswer> </Question> <Question> <questionId>TNHSCS010002</questionId> <question>CI builds are setup to ............</question> <Answer1> catch potentail build errors</Answer1> <Answer2> find bugs </Answer2> <Answer3> reduce build time </Answer3> <Answer4> None of the above </Answer4> <CorrectAnswer> catch potentail build errors </CorrectAnswer> </Question> <Question> <questionId>TNHSCS020001</questionId> <question>Jenkins is primiary used of ........</question> <Answer1> Nightly Builds </Answer1> <Answer3> CI Builds </Answer3> <Answer4> Report Generation </Answer4> <Answer1> All the above </Answer1> <CorrectAnswer> CI Builds </CorrectAnswer> </Question> <Question> <questionId>TNHSCS020002</questionId> <question>CI builds are setup to ............</question> <Answer1> catch potentail build errors</Answer1> <Answer2> find bugs </Answer2> <Answer3> reduce build time </Answer3> <Answer4> None of the above </Answer4> <CorrectAnswer> catch potentail build errors </CorrectAnswer> </Question>

In reply to Re^2: WxPerl Next button by saran73
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
  • 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.
  • 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 making s'mores by the fire in the courtyard of the Monastery: (9)
    As of 2015-07-07 23:45 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (93 votes), past polls