Perl tK Listbox question/help?

Posted on 2011-04-21
Medium Priority
Last Modified: 2012-05-11
I have the very basic perl script that has a tk list box that is populated by an array. The screen also has a button that calls a function. When the button is pressed I need the items or items that are selected in the list box to be populated into another array. I'm terrible with tK and can't figure out how to do it. Does anyone know how to do this? Hoping its pretty simple. Thanks!

use Tk;

$mw = MainWindow->new;
@choices = qw/dog cat fish bird/;
my $lb = $mw->Scrolled("Listbox", 
	-scrollbars => "osoe", 
	-selectmode => "multiple"
	)->pack(-side => "left");
$lb->insert("end", sort @choices);
$mw->Button(-text => "Selection To Array", -command => sub { &FillArray })->pack;

sub FillArray {

    my @ArrayItems;
    print "Code goes here.";


Open in new window

Question by:KGNickl
  • 2

Accepted Solution

KGNickl earned 0 total points
ID: 35451938
my @stuff = $$lb->get($lb->curselection( )) );

Then I just loops through the @stuff array and did a pack to add them into my own array 1x1. Not sure if its the best way, but it works and got the job done.

Author Closing Comment

ID: 35451942
Submitted before I went to sleep. When I woke up and no one had answered I just did some digging and figured out my own answer/solution to my question.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question