develooper Front page | perl.tcltk | Postings from March 2010

Scrolling a window

Thread Next
Swingle David-QWHM86
March 2, 2010 01:13
Scrolling a window
Message ID:
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.
use strict;
use Tkx;
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 =>
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');
Any help would be appreciated - David

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About