PrimeLord has asked for the wisdom of the Perl Monks concerning the following question:
The @selected_files array is never getting populated with any of the selections. Any help you can offer would be very appreciated. Thanks!#!perl -w use strict; use Tk; # Main Window my $mw = MainWindow->new; # Frames my $label3_frame = $mw->Frame; my $files_frame = $mw->Frame; my $exit_frame = $mw->Frame; # File Listing Label $label3_frame->Label(-text => "Select Files to Track")->pack(-side => +'left'); # File Listing Listbox my @files; push @files, $_ for <*.txt>; my $listbox = $files_frame->Scrolled("Listbox", -scrollbars => "oe", -selectmode => "extended")->pack; $listbox->insert('end', @files); # Print Listbox Button my @filenames; my @selected_files = $listbox->curselection; for (@selected_files) { my $file = $listbox->get($_); push @filenames, $file; } $exit_frame->Button(-text => "Files", -command => sub { print "@filenames\n"; })->pack; $exit_frame->Button(-text => "Exit", -command => sub { exit; })->pack; # Pack Frames $label3_frame->pack(-side => 'top', -fill => 'y'); $files_frame->pack(-side => 'top', -fill => 'y'); $exit_frame->pack(-side => 'top', -fill => 'y'); # Main Loop MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: TK Listbox help
by graff (Chancellor) on Mar 11, 2004 at 01:50 UTC |