Scrolling a window

[email protected] ("Swingle David-QWHM86")
Newsgroups perl.tcltk
Message-ID <[email protected]>
Hi, I'd like to scroll a window, but can't seem to get it work.  I've
seen and tried code that scrolls widgets such as a listbox, but I want
to scroll the entire window.  What I would prefer is that there be no
scroll bars unless the user shrinks the window size so that widgets are
now out of view.  First, I tried to associate the scrollbars with a
frame, but I would get errors.  So, I tried using a canvas instead.  The
code I have is below.  It will display scrollbars that do nothing.
 
<code>
use strict;
use Tkx;
Tkx::package_require("tile");
 
my $mw = Tkx::widget->new(".");
 
$mw->g_grid_columnconfigure(0, -weight=>1);
$mw->g_grid_rowconfigure(0, -weight=>1);
#$mw->new_ttk__sizegrip()->g_grid(-column => 1, -row => 1, -sticky =>
"se");
 
my $canvas = $mw->new_canvas();
$canvas->g_grid(-column=>0, -row=>0, -sticky=>"nwes");
 
my $hscroll = $mw->new_ttk__scrollbar(-orient => "horizontal", -command
=> [$canvas, "xview"]);
$hscroll->g_grid(-column => 0, -row => 1, -sticky => "we");
 
my $vscroll = $mw->new_ttk__scrollbar(-orient => "vertical", -command =>
[$canvas, "yview"]);
$vscroll->g_grid(-column => 1, -row => 0, -sticky => "ns");
 
$canvas->configure(-yscrollcommand => [$vscroll, "set"], -xscrollcommand
=> [$hscroll, "set"]);
 
foreach my $i (1 .. 10)
{
    my $labelText = "Label " . $i;
    my $label = $canvas->new_ttk__label(-text => $labelText);
    $label->g_grid(-column => $i, -row => $i, -sticky => 'w');
}
 
Tkx::MainLoop();
</code>
 
Any help would be appreciated - David
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.