Silverstrike has asked for the wisdom of the Perl Monks concerning the following question:
Running this code produces a very thin window with no contents. Adding# $main is MainWindow my $canvas = $main->Scrolled('Canvas', -scrollbars => 'e', -height => 200, -width => 200, )->pack; $canvas->packPropagate(0);
to the arguments given to Scrolled produces the same output.-scrollregion => [0,0,200,200],
Yet, when I insert some widgets, and just to test it lets add inmy $frame = $main->Scrolled('Canvas', -scrollbars => 'e', )->pack; my $canvas = $frame->Subwidget('canvas'); $canvas->configure(-height => 200, -width => 200); $canvas->packPropagate(0);
the contents of the canvas obviously exceed its specified height yet the scrollbar doesn't let me scroll up/down. Adding -scrollregion => [0,0,200,200] to the arguments given to configure affects nothing.foreach (1..20) { $canvas(or $frame)->Label(-text => 'test')->pack; }
Clicking on the scrollbar yields a slew of error messages. I've tried a few different lists in the -command option includingmy $canvas = $main->Canvas(-height => 200, -width => 200, )->pack(-side => 'left'); $canvas->packPropagate(0); my $scrollbar = $main->Scrollbar( -orient => 'vertical', -command => ['yview' => $canvas], )->pack(-fill => 'y', -side => 'right');
and to no avail. Any help here would be appreciated. I am assuming that I am missing something that is very simple here, possibly a need to inform the Canvas of the Scrollbar or something. I've looked online yet can only find examples of Scrollbars used with Listboxes, thus not helping me here. Thank you,['yview', $canvas, 'scroll', 1, 'units']
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A Canvas and a Scrollbar with Tk
by The Mad Hatter (Priest) on Dec 12, 2003 at 02:45 UTC | |
|
Re: A Canvas and a Scrollbar with Tk
by JamesNC (Chaplain) on Dec 12, 2003 at 13:00 UTC | |
|
Re: A Canvas and a Scrollbar with Tk
by pg (Canon) on Dec 12, 2003 at 17:02 UTC | |
|
Re: A Canvas and a Scrollbar with Tk
by Silverstrike (Novice) on Dec 12, 2003 at 19:55 UTC |