Debug error follows:use Tk; require Tk::BrowseEntry; #use warnings; use strict; my ($entry,$f,$mw,$top,$entry2,$f1); $mw = MainWindow->new(-title => "Organizational Chart Generator"); $mw->geometry( "800x400" ); $f = $mw->Frame(-borderwidth => 2, -relief => 'groove') ->pack(-side => 'top', -fill => 'x'); $entry = $f->Label(-text=>"Division Title:")->pack(-side => "left", -anchor => "n", -fill => "x", -expand => "y"); $entry = $f->Entry( -textvariable => '', -width => 40); $entry->pack(-side => "left", -anchor => "n", -fill => "x", -expand => "y"); my $addbutton = $f->Button(-text => "Add Chart Blocks", -command => \&addwidget )->pack(-anchor => 's'); my $addbutton2 = $f->Button(-text => "Generate Chart", -command => \&genchart )->pack(-anchor => 's'); $mw->Button(-text=>'exit', -command=>sub{exit;})->pack(); MainLoop; sub addwidget { my @divisions = qw (AF AF CSPL CSPL CSO DGG DG FR FRAT OC OCX OCX + OC); my @unique; my %seen; @unique = grep { ! $seen{$_}++ } @divisions; my @s = sort {$a cmp $b} @unique; my $f1 = $f->Frame->pack(-side => 'top', -expand => 1, -fill =>'y', -before => $addbutton); # my $f2 = $f->Frame->pack(-side => 'top', -expand => 1, # -fill =>'y', -before => $addbutton2); $mw = $f1->Label(-text=>"Division Unit:")->pack( -side => "left", -anchor => "n", -fill => "x", -expand => "y"); $mw = $f1->Entry( -textvariable => '', -width => 40); $mw->pack(-side => "left"); $f1->ScrlListbox(-label => 'Right-Hand Area of Chart', -selectmode => 'multiple', -height => 5, -listvariable => \@divisions, -exportselection => 0) ->pack(-ipady => '5', -side=>'left'); $mw = $f1->Entry(-textvariable => '', -width => 40); $mw->pack(-side => "left",); $f1->ScrlListbox(-label => 'Middle Area of Chart', -selectmode => 'multiple', -height => 5, -listvariable => \@divisions, -exportselection => 0) ->pack(-ipady => '5', -side=>'left'); $mw = $f1->Entry(-textvariable => '', -width => 40); $mw->pack(-side => "left",); $f1->ScrlListbox(-label => 'Right-Hand Area of Chart', -selectmode => 'multiple', -height => 5, -listvariable => \@divisions, -exportselection => 0) ->pack(-ipady => '5', -side=>'left'); } sub genchart { #This does not work my @inds = $f1->curselection(); my @sels; foreach my $i ( @inds ){ print $f1->get( $i ), "\n"; } #I have tried this, and no luck. # print join ':', map { $_->Subwidget('entry')->get } @be; }
I do not know how to pass the values from the gui to the subroutine I have named genchart(). Should I use a bind method via the Generate Chart submit button instead? I have tried to capture via the sub widget method, however, this does not work. I wonder if I should be building my widgets using the grid method as well.Tk::Error: Can't call method "curselection" on an undefined value at C +:\Users\Ettore Vecchione\Desktop\ORG CHART APP\chart.pl line 135. Tk callback for .frame.button1 Tk::__ANON__ at C:/Perl64/site/lib/Tk.pm line 251 Tk::Button::butUp at C:/Perl64/site/lib/Tk/Button.pm line 175 <ButtonRelease-1> (command bound to event)
In reply to TK Gui Help by GuiPerl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |