Hi there,
I am trying to create a GUI with a large number of textboxes which I would like to scroll - not the contents of the boxes but the boxes themselves. I would like to use maxsize to limit the size of the window, but when I do this I am then unable to see all of the textboxes and so would like to add a horizontal scrollbar. I have configured a scrollbar to move the textboxes vertically, but haven't figured out how to add a horizontal scrollbar that essentially moves the frame. Any help would be appreciated, thanks!

I'm using perl v. 5.6.0
and linux 2.4 i386
#!/usr/bin/perl -w use Tk; $top = MainWindow->new(); $top->maxsize(600,300); $NUMCOLS = 10; # Number of columns to display # Create a frame into which all the text boxes will go $frm = $top->Frame()->pack(); # Make and pack the scrollbar $scrollbar = $frm->Scrollbar()->pack(-side => 'left', -fill => 'y'); # Set up textboxes for ($i = 0; $i < $NUMCOLS; $i++) { $block[$i] = $frm->Text( -width => 20, -height => 30, -background => 'white', -yscrollcommand => ['set' => $scrollbar] ); for ($j = 0; $j < 100; $j++) { $block[$i]->insert('end',"$j\n"); } } ## Configure the scrollbar to scroll each textbox $scrollbar->configure(-command => sub { foreach $box (@block) { $box->yview(@_); }}); ## Pack the textboxes foreach $box (@block) { $box->pack(-side => 'left'); } MainLoop();

Edit by tye to add <readmore>


In reply to Help scrolling a series of textboxes with Tk by jeanine

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.