Re: Scrollbars in Perl::Tk
by pg (Canon) on Jan 15, 2004 at 03:12 UTC
|
You cannot pass Frame widget to Scrolled. Only those widgets that support -xscrollcommand and -yscrollcommand can be passed to Scrolled.
Unfortunately, at this point, no warning or error message will be given, and your attempt will just be quietly discarded.
| [reply] [Watch: Dir/Any] |
|
You cannot pass Frame widget to Scrolled.
I know you can(works for me).
#!/usr/local/bin/perl -W
#tk.scroll.frame.pl
use Tk;
use strict;
use vars qw($top $drop);
$top = new MainWindow;
$top->Label(-text => "Enter the scroll frame")->pack;
$top = $top->Scrolled('Frame', -scrollbars => "osoe",)->pack;
$top->Label(-text => "Inside the scroll frame")->pack;
$top->Label(-text => "Inside the scroll frame")->pack;
$top->Label(-text => "Inside the scroll frame")->pack;
$top->Label(-text => "Inside the scroll frame")->pack;
$top->Label(-text => "Inside the scroll frame")->pack;
$top->Label(-text => "Inside the scroll frame")->pack;
$top->Label(-text => "Inside the scroll frame")->pack;
$top->Label(-text => "Inside the scroll frame")->pack;
$top->Label(-text => "Inside the scroll frame")->pack;
$top->Label(-text => "Inside the scroll frame")->pack;
$top->Label(-text => "Inside the scroll frame")->pack;
MainLoop;
Anonymous Monk isn't showing enough code, but my ESP tells me he's got a logical error (not packing the frame he needs/wants it or not having it as a child of his scrollable frame or something).
update: screenshot on my Win2K box, perl5.6.1, Tk 800.025.
MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" | I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). | ** The third rule of perl club is a statement of fact: pod is sexy. |
| [reply] [Watch: Dir/Any] [d/l] |
|
For what it's worth, the example you posted runs without errors here, but yields a window without scrollbars.
Tk 800.024, Perl 5.8.0, on a gentoo linux install running mostly stable packages.
| [reply] [Watch: Dir/Any] |
|
Thanks, that appears correct. I'll find some other way around this problem and let you know the result. :-)
Dean
| [reply] [Watch: Dir/Any] |
Re: Scrollbars in Perl::Tk
by zentara (Archbishop) on Jan 15, 2004 at 16:05 UTC
|
I don't have an example handy right now, but often the Tk::Pane widget comes in handy when you need to add scrollbars. Just dump a scrolled Pane into the window.
my $pane = $mw->Scrolled('Pane', Name => 'scroll test',
-width => 600,
-height => 400,
-scrollbars => 'osoe',
-sticky => 'ne',
);
$pane->pack;
| [reply] [Watch: Dir/Any] [d/l] |
Re: Scrollbars in Perl::Tk
by zentara (Archbishop) on Jan 15, 2004 at 17:58 UTC
|
Well here is a script, that shows how to add scrollbars to a frame, using a pane.
#!/usr/bin/perl
use Tk;
use Tk::Pane;
my $mw = tkinit;
my $f = $mw->Frame(-bg=>'black')->pack;
my $p = $f->Scrolled('Pane', -scrollbars => 'osoe',)->pack;
$p->Label(-text => 'long label long label long label long label long l
+abel')->pack;
MainLoop;
| [reply] [Watch: Dir/Any] [d/l] |
Re: Scrollbars in Perl::Tk
by elef (Friar) on Jan 13, 2012 at 09:43 UTC
|
I bumped into this old thread looking for a way to make my main window scrollable. Both the suggested solutions work for me, but both are incomplete. With the code posted, the frame remains a postage stamp sized rectangle in the middle of the mainwindow when the mainwindow is resized. I added the options (-fill => 'both', -expand => 1) to pack for the frame (and pane) and now things look as they should.
For some strange reason, Scrolled even shrinks the frame it's added to. If I run PodMaster's code as is, the frame is too small to fit all the text.
Here's what PodMaster's code generates for me:
Default view of the window generated after removing the scrollbars from the code: http://dl.dropbox.com/u/16377950/kepek/scrollframe_1.png
PodMaster's version with what are intended to be optional scrollbars: http://dl.dropbox.com/u/16377950/kepek/scrollframe_2.png - note that both scrollbars are showing up even though they should disappear when the window is this large, and that text is left off both vertically and horizontally.
After adding (-fill => 'both', -expand => 1): http://dl.dropbox.com/u/16377950/kepek/scrollframe_3.png - horizontal scrollbar disappeared as the window is wide enough to show all text, vertical scrollbar showing up. | [reply] [Watch: Dir/Any] [d/l] [select] |
|
I bumped into this old thread looking for a way to make my main window scrollable.
Hi Please don't bump, zombies are hard to see :)
You should post a new question in Seekers Of Perl Wisdom and link to this old one
In the meantime, you could however consider this node for SOPW-ification, your choice :)
Regarding the code, I see the same images as you, but I'm not sure what behavior you're after or what you consider a problem.
Consider adding color :)
#!/usr/bin/perl --
use Tk;
use strict;
use vars qw($top $drop);
$top = tkinit( qw/ -background green /);
$top->Label( qw/ -background red /,
-text => "Enter the scroll frame"
)->pack;
$top = $top->Scrolled(
'Frame',
qw/ -background pink -scrollbars osoe /
)->pack( qw/ -fill both -expand 1 / );
$top->Label(
-text => "Inside the scroll frame $_"
)->pack for 1 .. 12;
MainLoop;
| [reply] [Watch: Dir/Any] [d/l] |