hackdaddy has asked for the wisdom of the Perl Monks concerning the following question:


Using Perl TK, I am looking to create a four-paned top window with text widgets in each pane: four equally-sized squares. A cross of Adjusters will perpendicularly separate the text widgets.

The user should be able to adjust vertically and horizontally the text widget panes.

Is this possible with the Adjuster widget? It seems like the Adjuster widget cannot intersect another Adjuster widget perpendicularly.

Replies are listed 'Best First'.
Re: Tk::Adjuster
by fglock (Vicar) on Sep 16, 2002 at 17:52 UTC

    You can divide the screen in two, then divide each half in two (needs 3 adjusters).

    | 2 --- | --- 3 | 1
Re: Tk::Adjuster
by hiseldl (Priest) on Sep 16, 2002 at 19:05 UTC
    In order to add more than one Adjuster you will need to use packAfter for all but the first Adjuster when you are pack'ing them.

    Here is a code snippet that demonstrates multiple Adjusters:

    #!perl -w use strict; use Tk 800.005; use Tk::TList; use Tk::DirTree; use Tk::Frame; use Tk::Scrollbar; use Tk::Adjuster; use vars qw/%tk/; $tk{mw} = MainWindow->new(-background => 'white'); $tk{mw}->geometry('500x400'); $tk{top_frame} = $tk{mw}->Frame; $tk{left_frame} = $tk{mw}->Frame; # # The first adjuster separates the left from the right # and since we want to control the left_frame size, we # assign the left_frame as the -widget. # $tk{adjuster} = $tk{mw}-> Adjuster(-widget=> $tk{left_frame}, -side=>'left'); $tk{right_frame} = $tk{mw}->Frame; $tk{dir_tree} = $tk{left_frame}->Scrolled('DirTree', -height=>'0', -width=>'0', -scrollbars=>'e', ); $tk{output_list} = $tk{right_frame}->Scrolled('TList', -height=>'1', -width=>'1', -scrollbars=>'osoe',); # # Create an adjuster that controls the right frame's top # widget, the output_list. The -side attribute specifies # which side the widget is on. # $tk{output_adjuster} = $tk{right_frame}-> Adjuster(-widget=> $tk{output_list}, -side=>'top'); $tk{user_list} = $tk{right_frame}->Scrolled('TList', -height=>'1', -width=>'1', -scrollbars=>'osoe',); # # Create an adjuster that controls the right frame's # use_list widget. # $tk{user_adjuster} = $tk{right_frame}-> Adjuster(-widget=> $tk{user_list}, -side=>'top'); $tk{group_list} = $tk{right_frame}->Scrolled('TList', -height=>'1', -width=>'1', -scrollbars=>'osoe',); $tk{dir_tree}->chdir( "." ); $tk{top_frame}->pack(qw/-side top -fill x/); $tk{left_frame}->pack(qw/-side left -fill y/); # # Use the normal pack for the first Adjuster # $tk{adjuster}->pack(qw/-side left -fill y/); $tk{right_frame}->pack(qw/-side right -fill both -expand 1/); $tk{dir_tree} ->pack(qw/-side left -fill both -expand 1/); $tk{output_list} ->pack(qw/-side top -fill both -expand 1/); $tk{user_list} ->pack(qw/-side top -fill both -expand 1/); $tk{group_list} ->pack(qw/-side top -fill both -expand 1/); # # Use packAfter here (see the Tk::Adjuster docs # for explanation) # $tk{user_adjuster}-> packAfter($tk{user_list},qw/-side top -fill y/); $tk{output_adjuster}-> packAfter($tk{output_list},qw/-side top -fill y/); MainLoop;

    If you are using the pack layout manager, you have to watch out for the order in which you pack the widgets or else you may get funny results.

    --
    hiseldl
    "Act better than you feel"