Hi,
I am new to perl TK world.
I am having doubt that for the below code.
How to take the value of selected and text box value from out of the loop.
#!/usr/bin/perl
use strict;
use Tk;
use Tk::BrowseEntry;
my $mw = MainWindow->new;
# Mainwindow: sizex/y, positionx/y
$mw->geometry("400x400+100+120");
&create_dropdown($mw);
my $mid_value;
$mid_value= \&create_dropdown_dit();
&create_dropdown_bot($mw);
#$ref = \&getGlobalName();
MainLoop;
sub create_dropdown {
my $toplam = shift;
# Create dropdown and another element which shows my selection
my $dropdown_value;
my $dropdown = $toplam->BrowseEntry(
-label => "Label",
-variable => \$dropdown_value,
)->place( -x => 100, -y => 15);
my $showlabel = $toplam->Label(
-text => "nothing selected",
)->place( -x => 280, -y => 15);
# Configure dropdown
$dropdown->configure(
# What to do when an entry is selected
-browsecmd => sub {
$showlabel->configure(-text => "You selected: $dropdown_value" ),
},
);
# Populate dropdown with values
foreach ( qw/apple banana pineapple grape/ ) {
$dropdown->insert('end', $_);
}
# Set the initial value for the dropdown
$dropdown_value = "Top value";
}
sub create_dropdown_bot {
my $botlam = shift;
# Create dropdown and another element which shows my selection
my $dropdown_value_bot;
my $dropdownbot = $botlam->BrowseEntry(
-label => "Label",
-variable => \$dropdown_value_bot,
)->place( -x => 100, -y => 75);
my $showlabel = $botlam->Label(
-text => "nothing selected",
)->place( -x => 280, -y => 75);
# Configure dropdown
$dropdownbot->configure(
# What to do when an entry is selected
-browsecmd => sub {
$showlabel->configure(-text => "You selected: $dropdown_value_bot" ),
},
);
# Populate dropdown with values
foreach ( qw/apple banana pineapple grape/ ) {
$dropdownbot->insert('end', $_);
}
# Set the initial value for the dropdown
$dropdown_value_bot = "Bottom value";
}
sub create_dropdown_dit {
#my $di_thick = shift;
# Create dropdown and another element which shows my selection
#my $di_thick_value;
# A label to show what to type in
my $label_wert = $mw->Label(
-text => 'mid value:',
)->place( -x => 30, -y => 45);
# This is the text-userinput field
my $entry_wert = $mw->Entry(
# width is in characters, not pixel
-width => 20,
)->place( -x => 130, -y => 45);
my $submit_but = $mw->Button(
-text => "Execute",
# call a sub somewhere
-command => \&submit_action,
)->place( -x => 130, -y => 135);
}
print $mid_value
Like mid_value i need to see after the loop.
Thanks in advance,
K.Vasanth