#!/usr/bin/perl use Tk; #also check out the Pane widget. use Tk::Frame; use Tk::Canvas; use Tk::Button; my $mw = new MainWindow; my $sc = $mw->Scrolled( 'Canvas', -bg => 'black', -scrollbars => 'w', ); my $sf = $sc->Frame( -background => 'Yellow' ); foreach ( 1 .. 100 ) { my $subframe = $sf->Frame(); my $lbl = $subframe->Label( -text => "Entry $_" ) ->pack( -side => 'left', -fill => 'x' ); my $txt = $subframe->Entry()->pack( -side => 'right', -fill => 'x' ); $subframe->pack( -side => 'top', -fill => 'x' ); } # Find the required width / height of our frame... $sf->update; # forces geometry requests to propagate my $f_req_w = $sf->reqwidth; my $f_req_h = $sf->reqheight; print "- Frame needs $f_req_w by $f_req_h\n"; # Configure the scrolled canvas for a best fit... $sc->configure( -scrollregion => [ 0, 0, $f_req_w, $f_req_h ], -width => $f_req_w ); $sc->createWindow( 0, 0, -anchor => 'nw', -window => $sf, -height => $f_req_h, -width => $f_req_w, ); $sc->pack( -expand => 1, -fill => 'both' ); Tk::MainLoop; __END__