See sub PM899927
#!/usr/bin/perl -- use strict; use warnings; use Tk; use Tk::Wizard; Main(@ARGV); exit(0); sub Main { @_ ? T160() : PM899927(); } #~ http://perlmonks.org/?node_id=899927 #~ Confused by variable scope in Tk::Wizard sub PM899927 { my $wiz = new Tk::Wizard( -title => "Kickstart Wizard" ); my $oschoice = 'test'; $wiz->addSingleChoicePage( -text => 'Choose OS', -variable => \$oschoice, -choices => [ { -title => 'Linux', -value => 'Lin' }, { -title => 'Windows', -value => 'Win', -selected => 1, }, ], -preNextButtonAction => sub { warn "\$oschoice $oschoice "; } +, ); $wiz->addPage( sub { #~ shift->_text_frame( $wiz->_text_frame( { -title => 'Partitioning', -boxedtext => \"/mirror/inifiles/partition.$oschoi +ce", } ); }, ); $wiz->Show; $wiz->focus; MainLoop; } ## end sub PM899927
#~ http://cpansearch.perl.org/src/LGODDARD/Tk-Wizard-2.151/t/160_textb +ox.t sub T160 { local $ENV{TEST_INTERACTIVE} = 1; my $wizard = Tk::Wizard->new; $wizard->addSplashPage( -wait => $ENV{TEST_INTERACTIVE} ? 0 : 1, ) +; $wizard->addTextFramePage( -wait => $ENV{TEST_INTERACTIVE} ? 0 : 1, -title => "1: Text from literal", -boxedtext => \"This is in a box", # " ); $wizard->addTextFramePage( -wait => $ENV{TEST_INTERACTIVE} ? 0 : 1, -subtitle => sprintf( "2: Text from filename (%s)", __FILE__ +), -boxedtext => __FILE__, ); $wizard->Show; MainLoop; } ## end sub T160 __END__
http://cpansearch.perl.org/src/LGODDARD/Tk-Wizard-2.151/lib/Tk/Wizard. +pm sub addTextFramePage { my ($self, $args) = (shift, {@_}); DEBUG "addTextFramePage args are ", Dumper($args); return $self->addPage( sub { $self->_text_frame($args) } ); } sub _text_frame { my $self = shift; my $args = shift; DEBUG "Enter _text_frame with ", Dumper($args); my $text; my $frame = $self->blank_frame(%$args); if ( $args->{-boxedtext} ) { if ( ref $args->{-boxedtext} eq 'SCALAR' ) { $text = $args->{-boxedtext}; } elsif ( not ref $args->{-boxedtext} ) { open my $in, $args->{-boxedtext} or Carp::croak "Could not read file: $args->{-boxedtex +t}; $!"; read $in, $$text, -s $in; close $in; WARN "Boxedtext file $args->{-boxedtext} is empty." if not + length $text; } } $$text = "" if not defined $text; my $t = $frame->Scrolled( "ROText", -background => ( $args->{ -background } || 'white' ), -relief => "sunken", -borderwidth => "1", -font => $self->{defaultFont}, -scrollbars => "osoe", -wrap => "word", )->pack(qw/-expand 1 -fill both -padx 10 -pady 10/); $t->configure( -background => 'green' ) if DEBUG_FRAME; $t->insert( '0.0', $$text ); $t->configure( -state => "disabled" ); return $frame; }

In reply to Re: Confused by variable scope in Tk::Wizard by Anonymous Monk
in thread Confused by variable scope in Tk::Wizard by rgcosma

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.