Perl tK Listbox question/help?

Posted on 2011-04-21
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
    LVL 5

    Accepted Solution

    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.
    LVL 5

    Author Closing Comment

    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

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
    In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (…
    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…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now