When i try to print the selected items in both the lists in another subroutine, i get the following error:sub meter{ my $metw = MainWindow-new; $metw->geometry("500x500"); $metw->title("Meter work details"); $metw->configure(-background=>'purple'); my $frame8=$metw->Frame(-relief=>'groove', -borderwidth=>3, -backgrou +nd=>'blue',)->pack(-side=>'top', -pady=>15, -padx=>15); my $label8=$frame8->Label(-text=>'Enter consumer name',-background=>'b +lue', -foreground=>'white',)->pack(-side=>'left'); $entry8=$frame8->Entry(-width=>30,-background=>'white')->pack(-side=>' +left', -pady=>3); ($label10 = $metw->Label(-text=>'Double click on subdivision name',-ba +ckground=>'blue', -foreground=>'white'))->pack(-side=>'top',-pady=>2) +; $sd_list = $metw->Listbox(-exportselection => 0)->pack; $sd_list->insert('end', "loc1","loc2","loc3","loc4","loc5","loc6", "lo +c7", "loc8", "loc9","loc10","loc11","loc12","loc13"); $sd_list->bind('<Double-1>', \&meter_subdivision); sub meter_subdivision { my $sd = $sd_list->get('active'); return $sd; } ($space16 = $metw->Label(-text=>' ',-background=>'purple') +)->pack; ($space17 = $metw->Label(-text=>' ',-background=>'purple') +)->pack; ($labeln = $metw->Label(-text=>'Double click on appropriate option',-b +ackground=>'blue', -foreground=>'white'))->pack(-side=>'top',-pady=>2 +); $nr_list = $metw->Listbox(-listvariable => $_, -exportselection => 0)- +>pack; $nr_list->insert('end',"New service","Replacement"); $nr_list->bind('<Double-1>',\&type_meter_work); sub type_meter_work { my $tmw = $nrd_list->get('active'); return $tmw; } ($space8 = $sw->Label(-text=>' ',-background=>'purple'))-> +pack; ($space9 = $sw->Label(-text=>' ',-background=>'purple'))-> +pack; my $label7=$metw->Label(-text=>'Enter phase : single/three',-backgroun +d=>'blue', -foreground=>'white',)->pack(-side=>'top'); $entry7=$metw->Entry(-width=>30,-background=>'white')->pack(-side=>'to +p', -pady=>3); $space10 = $sw->Label(-text=>' ',-background=>'purple'))-> +pack; $space11 = $sw->Label(-text=>' ',-background=>'purple'))-> +pack; $metw->Button(-text=>'Print receipt',-background=>'blue',-command=>\&m +eter_fwrite_print)->pack(-side=>'top',-pady=>2); }
If i have only one listbox in the window the value of the selected item is printed just fine.Tk::Error: Can't call method "get" on an undefined value at C:\Perl\pr +ograms\cash_counter.pl line 167. <Double-Button-1> (command bound to event)
In reply to Perl/Tk listbox question by perl_seeker
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |