Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Array to scroll..

by rinceWind (Monsignor)
on Jul 27, 2006 at 13:55 UTC ( [id://564091]=note: print w/replies, xml ) Need Help??


in reply to Array to scroll..

Granted it's possible to prepopulate the Tk::Text widget as zentara has shown.

My thoughts are that perhaps you should be using a scrolled Tk::Listbox object, which has a tied interface that you can use with your @arr, if you want changes to @arr to appear in the box automagically.

--

Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ?
(Missquoting Janis Joplin)

Replies are listed 'Best First'.
Re^2: Array to scroll..
by tamaguchi (Pilgrim) on Jul 27, 2006 at 15:34 UTC
    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?
      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"; } }

      I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://564091]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-03-29 14:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found