in reply to How to create a scrollbar for multiple objects in TK

use scrolled:

use Tk; use Tk::Pane; $mw = MainWindow->new(); $mw->geometry('+0+0'); $mw->title( "Many buttons" ); ## Create Frame of elements my $frame= $mw->Scrolled('Frame', -relief => 'groove', -bd => 1, -scrollbars=>"se"); $frame->pack(-fill => 'both', -expand => 1); my $num_of_buttons=10; #my num_of_buttons=40; while ($num_of_buttons > 0) { ## Create Button of elements my $button = $frame->Button( -font => 'system', -text => "test", -activebackground => 'cyan', -width => 34, -state => "active", -relief => "raised", ); $button->pack( -side => 'top', -fill => 'x' ); $num_of_buttons--; } MainLoop();

Replies are listed 'Best First'.
Re^2: How to create a scrollbar for multiple objects in TK
by vios (Novice) on Nov 11, 2004 at 06:12 UTC

    I have tried this snippet of code but I see no different between this and the original code. No scrollbars are seen anywhere. I believe the scrollbar also need also to be configured before it can be used.

    Vicky

      "I have tried this snippet of code but I see no different between this and the original code. "

      The solution was tested before I post it, as I always do. My testing was done on WinXP with AS Perl 5.8.4.

      "No scrollbars are seen anywhere."

      I saw scrollbars around the main frame (actually not really the main frame, but the frame added on top of it, but visually it looks like the scrollbars are for the main frame.) And when you resize the window, the scrollbars move along.

      "I believe the scrollbar also need also to be configured before it can be used. "

      I did configured scrollbars with Scrolled.

        Very strange. I also don't see any different. I am running the sample on Windows XP Service pack 2, Perl V5.8.0 and Tk version 800.024. I just get the buttons but no scrollbar or no scrolling is happening. It works fine if I use a text widget instead of a frame, in that case I will get the scrollbars.

        Pieter

      I came up with the same thing, but mine didn't work at all in practice either, though it should.

      I'm using perl 5.8.0 on i386 linux

      Maybe Scrolled has a platform dependant bug, and Tk::Scrollbar has to be used instead?


      --
      Snazzy tagline here