Your code is a bit to hard for me to patch up, so I will show you some tips using the code I showed in the node above.

First, you want to make a single Scrolled Pane to hold as many widget sets as you need. I may have misled you by making a Scrolled Pane for each widget set, but these are just demonstration scripts. :-).

Now, for each widget set, you make a frame, add your widgets to the frame, and pack the Frames into your Scrolled Pane. To get all the data out when the selection button is pushed, loop thru all your hash keys, then insert the data into your entry boxes. You can add as many frames as you want, they will just be off in the Scrolled Pane. If you want to keep all widgets showing, you could make a few rows with a Scrolled Pane in each row. I've included a second example of doing this below, using canvases as the widget, but you can put whatever you want in there. Notice the various -expand and -fill packing options, allowing the window to be resized correctly.

If you want to make individual buttons to load each entry separately, just add a button to each frame to just loop thru that portion of the hash.

#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Pane; my $mw = MainWindow->new; $mw->geometry(q/600x400+100+100/); $mw->title("Test Script"); #need exportselection=>0 for using multiple selection boxes my %lbhash; # you want to use the listbox to hold your # data, so store the widget's actual object # with the name you want to give it my @choices = ('afg', 'dfg', 'erty', 'etc', 'foo','bar','wxyz'); # main Pane for all widget groups my $main_pane = $mw->Scrolled('Pane', -bg=>'black', -scrollbars=>'osoe', -sticky=>'nwse', )->pack(-expand=>1, -fill=>'both'); foreach my $choice(@choices){ # main frame for each widget set my $frame = $main_pane->Frame(-bg=>'lightblue') ->pack(-side => 'left', -expand=>1, -fill=>'y'); my $label = $frame->Label(-text=> $choice, -bg=>'hotpink') ->pack(-side=>'top'); $lbhash{ $choice }{'entry'}= $frame->Entry( -bg=>'lightyellow') ->pack(-side=>'top'); $lbhash{ $choice }{'widget'} = $frame->Scrolled('Listbox', -bg => 'white', -selectmode => 'extended', -exportselection=> 0 ) ->pack(-side=>'top', -expand=>1, -fill=>'y'); my @random_data; for(1..20){push @random_data ,int rand(100) } $lbhash{ $choice }{'widget'} ->insert( 'end', @random_data ); } $mw->Button( -text => "Selections", -command => sub{ foreach my $key( keys %lbhash ){ my @selects = $lbhash{ $key }{'widget'}->curselection; print "$key: "; my @inserts; foreach my $select (@selects){ push @inserts, $lbhash{ $key }{'widget'}->get($selec +t); } my $insert_string = join " ", @inserts; $lbhash{ $key }{'entry'}->insert(0, $insert_string); } } )->pack( -side => 'bottom' ); $mw->Button( -text => "Done", -command => \&exit )->pack; MainLoop;

A second example showing how to load a Scrolled Pane to act like a scrollable grid.

#!/usr/bin/perl use strict; use Tk; use Tk::Pane; my $mw = MainWindow->new; $mw->geometry('400x250'); my $mwf = $mw->Scrolled('Pane', -scrollbars=>'osoe', -sticky=>'nwse', )->pack(-expand=>1, -fill=>'both'); my %frame; # hash for holding frames for (1..4){ $frame{$_} = $mwf->Frame()->pack(-expand=>1,-fill=>'both'); } my %canv; for (0..4){ $canv{$_}{'obj'} = $frame{1}->Scrolled('Canvas', -height => 100, -width => 100, -bg =>'white', -scrollbars => 'osoe', -scrollregion => [ 0, 0, 500, 500 ], )->pack(-side =>'left' ,-padx=>10,-pady=>10, -expand=>1, -fill=>'bo +th'); $canv{$_}{'obj'}->createText(50,50, -text => $_, -anchor => 'center', ); } for (5..9){ $canv{$_}{'obj'} = $frame{2}->Scrolled('Canvas', -height => 100, -width => 100, -bg =>'lightseagreen', -scrollbars => 'osoe', -scrollregion => [ 0, 0, 500, 500 ], )->pack(-side =>'left', -padx=>10,-pady=>10 ,-expand=>1, -fill=>'bo +th'); $canv{$_}{'obj'}->createText(50,50, -text => $_, -anchor => 'center', ); } for (6..10){ $canv{$_}{'obj'} = $frame{3}->Scrolled('Canvas', -height => 100, -width => 100, -bg =>'yellow', -scrollbars => 'osoe', -scrollregion => [ 0, 0, 500, 500 ], )->pack(-side =>'left', -padx=>10,-pady=>10 ,-expand=>1, -fill=>'bo +th'); $canv{$_}{'obj'}->createText(50,50, -text => $_, -anchor => 'center', ); } for (11..15){ $canv{$_}{'obj'} = $frame{4}->Scrolled('Canvas', -height => 100, -width => 100, -bg =>'hotpink', -scrollbars => 'osoe', -scrollregion => [ 0, 0, 500, 500 ], )->pack(-side =>'left', -padx=>10,-pady=>10 ,-expand=>1, -fill=>'bo +th'); $canv{$_}{'obj'}->createText(50,50, -text => $_, -anchor => 'center', ); } 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.