First, ditto on the comments above. You make $f1 a global, but you create the scrolled listbox in another sub using my $f1. The $f1 won't be seen in genchart that way.

You also don't need "use Tk::BrowseEntry" since you are using scrolled listboxes.

Your code is pretty messed up to try and fix, but I will show you how to get the selections out of a set of scrolled listboxes. Notice in the following example, the indice count starts at 0, and to get the text of the indice you need to run $lb->get on it.

#!/usr/bin/perl use strict; use warnings; use Tk; my $mw = MainWindow->new; $mw->geometry(q/+100+100/); $mw->title("Test Script"); #need exportselection=>0 for using multiple selection boxes my $lb0 = $mw->Listbox(-bg => 'white', -selectmode => 'extended', -exportselection=> 0 )->pack; $lb0->insert( 'end', qw/foo bar baz/ ); my $lb1 = $mw->Listbox(-bg => 'lightseagreen', -selectmode => 'extended', -exportselection=> 0 )->pack; $lb1->insert( 'end', 1..20 ); print "$lb0 : $lb1\n"; $mw->Button( -text => "Selections", -command => sub{ print "1: ", join(" ", $lb0->curselection), "\n", "2: ", join(" ", $lb1->curselection), "\n", "\n"; my @selections0 = $lb0->curselection; my @selections1 = $lb1->curselection; foreach my $select (@selections0){ print $lb0->get($select) +,"\n"}; foreach my $select (@selections1){ print $lb1->get($select) +,"\n"}; } )->pack( -side => 'left' ); $mw->Button( -text => "Done", -command => \&exit )->pack; MainLoop;

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

In reply to Re: TK Gui Help by zentara
in thread TK Gui Help by GuiPerl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.