The scroll is actually an scrolled entry box. I would like to get the values out of the scrolled entrybox by like it is possible to get the value out of a normal entry box with the method "get". Is there any equivalent method that could be used to get the values out from the entry box? | [reply] [Watch: Dir/Any] |
I've never heard of a scrolled entry box, but maybe this is what you are looking for with a scrolled Listbox. It seems that you should read a book on Tk, these questions are very simple.
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
# Main Window
my $mw = MainWindow->new;
# Frames
my $tf_frame = $mw->Frame->pack();
my $f_frame = $mw->Frame->pack();
my $bf_frame = $mw->Frame->pack();
# File Listing Label
$tf_frame->Label(-text =>
"Select Items")
->pack(-side => 'left');
my @items = (1..500);
my $listbox = $f_frame->Scrolled("Listbox",
-scrollbars => "oe",
-selectmode => "extended")->pack;
$listbox->insert('end', @items);
$bf_frame->Button(-text => "Done",
-command => sub { &print_names($listbox);
exit;
})->pack;
MainLoop;
sub print_names{
my $listbox = shift;
my @selected_items = $listbox->curselection;
for (@selected_items) {
my $item = $listbox->get($_);
print "$item\n";
}
}
| [reply] [Watch: Dir/Any] [d/l] |