Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Scrollbars in Perl::Tk

by elef (Friar)
on Jan 13, 2012 at 09:43 UTC ( #947715=note: print w/replies, xml ) Need Help??

in reply to Scrollbars in Perl::Tk

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:
PodMaster's version with what are intended to be optional scrollbars: - 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): - horizontal scrollbar disappeared as the window is wide enough to show all text, vertical scrollbar showing up.

Replies are listed 'Best First'.
Re^2: Scrollbars in Perl::Tk
by Anonymous Monk on Jan 13, 2012 at 10:41 UTC

    I bumped into this old thread looking for a way to make my main window scrollable.


    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;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://947715]
[Cosmic37]: I'm wondering whether there is a specific/(or at least "usual") command or does one take a copy before undefining and then copy it back after slurping file into a string?
[BarApp]: I need help accessing perl files. I need permission!!!
[Cosmic37]: I wish thee a peachy life and express gratitude for considering my pathetic questions
[erix]: record separator
[Cosmic37]: Permissions are interesting earthlings. Did nature determine who gives permission and who asks permission. Who was the first to get permission? Are you not related to them as one big earthling family?
[karlgoethebier]: Cojones! We need cojones!
[karlgoethebier]: Ouch! Permissions! We need permissions!

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2017-06-29 16:39 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (672 votes). Check out past polls.