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

Hello,

I'm designing a dialogue window that should display values of a number of parameters from a number of experiments. The layout is firstly a frame to the left in the window that contains the names of all parameters. Then there is a second frame (to the right of the first one) in which the values of the parameters for each experiment are displayed.

Since the number of experiments are variable I would like to have a horizontal scrolling function of the frame containing the parameter values. How can I do this? I tried to connect a scrollbar to the frame (ttk__frame) in the same way as one can do to a listbox but this does not work. I guess that a frame is not a scrollable widget then. So my question is if there is some appropriate widget that can be used here, that in fact is scrollable?

I'm using ActivePerl 5.10 on WinXP and I have been writing my interface using Perl tkx.

Thank you in advance!

Replies are listed 'Best First'.
Re: Scrollable widgets
by Anonymous Monk on Apr 14, 2009 at 08:24 UTC
Re: Scrollable widgets
by Marshall (Canon) on Apr 14, 2009 at 13:15 UTC
    A Frame is definitely a "scrollable" widget!! It sounds like you aren't using enough frames! It sounds like you are creating rows. Make an ALL_ROWS frame. Within that frame make another frame which you pack a bunch of stuff horizontally. Make yet another frame for each row. Put all of the "row frames" into the ALL_ROWS frame. Do that for a few rows..10 or so. Now you should be able to make the ALL_ROWS frame "scrollable" and specify coordinates for the scrollbar.
Re: Scrollable widgets
by Marshall (Canon) on Apr 14, 2009 at 14:21 UTC
    Upon more reflection, it sounds like your app is like a spreadsheet. So I offer some code to get you started if you want to go that way. This is a bit different than packing your own widgets although you can do that!

    The TableMatrix data structure is weird in that coordinates are "$row,$column" as a single hash key. Anyway here is some runnable code for you to play with...of course the details can get very complex! Like when you click on a square with left,right,middle mouse context and want pop-up menus and such.

    Unless this critter has to be interactive with the user, I would suggest making a .CSV file or .XLS Excel file and using that for the display. Anyway here is a simple framework to make a Tk spreadsheet:

    #!/usr/bin/perl -w use strict; use Tk; use Tk::TableMatrix::Spreadsheet; my %hash; my $mw = MainWindow -> new; $mw -> title ("Just Some Demo"); $mw ->Button(-text => "Quit!", -command => sub {exit} ) ->pack; my $top = $mw->Scrolled('Spreadsheet', -rows => 21, -cols => 11, -width => 6, -height => 12, -titlerows => 1, -titlecols => 0, -variable => \%hash, -selectmode => 'single', -resizeborders => 'both', -bg => 'white', )->pack(-expand =>1, -fill=>'both'); $hash{"0,1"}="xyzzy"; $hash{"2,3"}="coord:2,3"; MainLoop;
    Tk is cool and lot's can be done with it.