Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: TK Scrollbars not working correctly

by hiseldl (Priest)
on Jan 22, 2003 at 15:20 UTC ( #229040=note: print w/replies, xml ) Need Help??


in reply to TK Scrollbars not working correctly

If you want the canvas to be the size of the image AND the scrollbars to fit in that canvas, then you will have to

  1. create another frame the size of your image, and
  2. create the canvas and place it in the frame
It should look something like this:

my $main_frame = tkinit(); # make this frame the size of your image my $canvas_frame = $main_frame->Frame( ...options... ); my $tcanvas = $canvas_frame->Scrolled('Canvas', ...options...); my $canvas = $tcanvas->Subwidget('canvas');

Try making the frame smaller than the image to see that the scrollbars appear as you want them. Also, you need to combine the '-scrollbar' options as mentioned before.

--
hiseldl
What time is it? It's Camel Time!

Replies are listed 'Best First'.
Re: Re: TK Scrollbars not working correctly
by Popcorn Dave (Abbot) on Jan 23, 2003 at 04:52 UTC
    Actually the only time I want to see the scrollbars is when the image is larger than 300 x 300. That's why I tried to do the optional bit. My thinking is, after reading the replies, that I should probably test the size of my graphic in the subroutine that gets the size, see if it's over my defined limit and build a string of what I want to see as scrollbars rather than use the optional bit. That may be a bit of a kludge, but using -scrollbars => 'osow' makes them both disappear.

    There is no emoticon for what I'm feeling now.

        the only time I want to see the scrollbars is when the image is larger than 300 x 300

      Aha! I think you want to set the -scrollregion. Set the -scrollregion after you have populated the canvas so that the scrollbars can reset to where they need to be. I loaded a 300x300 image and the scrollbars were not there, then I loaded a 400x400 image and the scrollbars both appeared.

      use Tk 800.000; use Tk::Canvas; use strict; my $main = Tk::MainWindow->new(); my $canvas=$main->Scrolled('Canvas', -scrollbars => 'osoe', -bg=>'white', -width=>300, -height=>300, )->pack(); my $image300x300 = $canvas->Photo(-file=>'300x300.gif'); my $image400x400 = $canvas->Photo(-file=>'400x400.gif'); my $id = $canvas->createImage(200,200,-image => $image400x400); # configure the scrollregion AFTER you populate the # canvas widget to reset the scrollbars $canvas->configure( -scrollregion => [ $canvas->bbox("all") ]); MainLoop;

      Is this what you're looking for?

      --
      hiseldl
      What time is it? It's Camel Time!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://229040]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2022-05-24 19:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (84 votes). Check out past polls.

    Notices?