#!/usr/bin/perl # Highly Modified CppTrial-pg225.pl in Answer to Perl Monks question # Cross-Platform GUI Programming with wxWidgets - Smart, Hock, & Csomor # 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', wxDefaultPosition, wxDefaultSize); # Parse your XML into $title, $question, & @choices and pass into subroutine, loop for all questions myStdDialogs1($frame); # Duplicate calls to simulate a loop myStdDialogs2($frame); # Duplicate calls to simulate a loop $frame->Show; $app->MainLoop; sub myStdDialogs1 { my ( $self ) = @_; my $title = "Survey question: TNHSCS010001"; # Hard coded 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, $question, $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 coded 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, $question, $title, \@choices); if( $singleChoiceDialog->ShowModal() == wxID_OK) { Wx::MessageBox($singleChoiceDialog->GetStringSelection(), "Selected Answer", wxOK | wxICON_INFORMATION, $self); } $singleChoiceDialog->Destroy; }