I've written up this example:
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
my $mw = MainWindow->new;
$mw->geometry("300x300");
my $var =1;
my ($major, $other);
my @options = ('one', 'two', 'three', 'four', 'five');
my $topics1=$mw->Radiobutton(-text =>'Selection 1', -value => '0',
-variable => \$major, -command => sub {&do_smth('1')})->pack(
+);
my $topics2=$mw->Radiobutton(-text =>'Selection 2', -value => '1',
-variable => \$major, -command => sub {&do_smth('2')})->pack()
+;
my $topics3=$mw->Radiobutton(-text =>'Selection 3', -value => '3',
-variable => \$major, -command => sub {&do_smth('3')})->pack()
+;
if ($var eq 'more'){
my $options=$mw->Optionmenu( -options => [@options], -variable
+ => \$other,
-command => [sub {&do_more($major, $other);}])->pack()
+;
}
MainLoop;
sub do_smth{
my $selection = shift;
$var='more' unless ($selection == 2);
}
sub do_more{
my ($major, $other) = @_;
print "do this: $other while Selection was $major\n";
}
How do I make the extra Optionmenu to appear when choice 2 is called?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.