in reply to Re^3: how can i create a scrollbar in the main window using perl tk
in thread how can i create a scrollbar in the main window using perl tk

Thanks!! Can i associate frames with the scrollbar? If yes then How? Also there are multiple frames, how can I associate the scrollbar with all of them?
  • Comment on Re^4: how can i create a scrollbar in the main window using perl tk

Replies are listed 'Best First'.
Re^5: how can i create a scrollbar in the main window using perl tk
by zentara (Cardinal) on Dec 18, 2008 at 14:11 UTC
    If you want to control the bindings of your scrollbars manually, it is a PITA full of details. Here is a decent example

    However, if you don't need the same scrollbar linking multiple widgets, you usually just use a scrolled Pane, and add frames to the scrolled Pane, then addwhatever you want to the Frames. Like:

    #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Pane; my $mw = tkinit; my $spane = $mw->Scrolled('Pane', -scrollbars => 'osoe', -bg => 'blue', )->pack(-expand => 1, -fill => 'both'); # create 2 frames side by side in the pane, and fill with more frames my $lframe = $spane->Frame(-bg=>'red')->pack(-side=>'left',-padx=>3); my $rframe = $spane->Frame(-bg=>'red')->pack(-side=>'right',-padx=>3); my %frames; for(1..100){ $frames{$_}{'frame'} = $lframe->Frame()->pack(-pady => 5 ); $frames{$_}{'label'} = $frames{$_}{'frame'}->Label(-text=>'Frame '.$ +_)->pack; my $num = $_; $frames{$_}{'button'} = $frames{$_}{'frame'}->Button( -text=>'Button '.$_, -command => sub{print "$num pressed\n"}, )->pack; } for(101..200){ $frames{$_}{'frame'} = $rframe->Frame()->pack(-pady => 5 ); $frames{$_}{'label'} = $frames{$_}{'frame'}->Label(-text=>'Frame '.$ +_)->pack; my $num = $_; $frames{$_}{'button'} = $frames{$_}{'frame'}->Button( -text=>'Button '.$_, -command => sub{print "$num pressed\n"}, )->pack; } MainLoop;

    I'm not really a human, but I play one on earth Remember How Lucky You Are
      Thanks a lot..Zentara You always Rock..
        How can I get the focus on the scroll bar, by default?
Re^5: how can i create a scrollbar in the main window using perl tk
by imrags (Monk) on Dec 18, 2008 at 10:00 UTC
    Check the same documentation.
    A frame is just another widget...
    You can link different type of widgets to scrolled.
    So that should not be a problem for you.
    If it doesn't work, You can always go back to Scrolled method for doing the same.
    Raghu