Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, I am trying to develop a tabular gui consisting of field/value pairs. The rows will be extensible so they need to be scrolled. So I embedded my entries in a scrolled text . However, the scrolling does not work properly. What am I missing? Is there a better way to do this? I tried tablematrix but it does not work with Activestate Perl. Thank you.
use Tk; my $mw =MainWindow-> new (-title => "Demo"); $mw->geometry('340x300'); my $frame = $mw->Frame->pack(-expand => 1, -fill => 'both'); my $frame_tl= $frame->Scrolled('Text', -scrollbars => 'se', )->pack(-expand => 1, -fill => 'both'); for (1..13){ my $f = $f.$_; $f= $frame_tl->Frame(-borderwidth =>2, -relief=> 'groove')->pack(-s +ide => 'top', -fill => 'x'); $f->Label(-relief => 'groove',-text=>" $_ :" )->pack(-side => 'left +', -fill => 'y'); $f->Entry(-takefocus => 1,-width => 60, -textvariable=>\$_)->pack(- +side => 'left', -fill => 'y'); } MainLoop;

Replies are listed 'Best First'.
Re: scrolled Embedded Text in Perl TK
by rinceWind (Monsignor) on Apr 13, 2007 at 06:55 UTC

    I think you need to look at Tk::HList for what you want. This will give you the ability to have a scrolled, long list of items. You can go two dimensional with it, for your field values.

    Although you may think of HList for handling nested structures, e.g. directories, you don't have to use that functionality to get the benefit of scrolled, extensible lists.

    --
    Apprentice wetware hacker

Re: scrolled Embedded Text in Perl TK
by zentara (Cardinal) on Apr 13, 2007 at 11:33 UTC
    Hi, trying to use the Scrolled Text widget is the wrong choice. You want a Scrolled Pane. Additionally, you should use a hash, instead of the $scalar concantation to make your entry names. That way you can access them easily by frame number.
    #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Pane; my $mw =MainWindow-> new (-title => "Demo"); $mw->geometry('340x300'); my $frame_tl= $mw->Scrolled('Pane', -scrollbars => 'se', )->pack(-expand => 1, -fill => 'both'); my %f; for (1..13){ $f{$_}{'frame'}= $frame_tl->Frame(-borderwidth =>2, -relief=> 'groo +ve') ->pack(-side => 'top', -fill => 'x'); $f{$_}{'label'} = $f{$_}{'frame'}->Label(-relief => 'groove',-text= +>" $_ :" ) ->pack(-side => 'left', -fill => 'y'); $f{$_}{'entry'}= $f{$_}{'frame'}->Entry(-takefocus => 1,-width => 6 +0, -textvariable=>\$_) ->pack(-side => 'left', -fill => 'y'); } MainLoop;

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