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

Several Monks kindly suggested that I use the DynaTabFrame to overcome problems I was having with the normal tabbed frame.
I have started to do this and am very pleased with the results.
I use the grid geometry manager and I found that I needed to have ->pack() at the end of each call to add which adds a tabbed frame.
Without the pack the tabbed frames were not displayed correctly.
I am more than content to do this but I wondered if this the best thing to do.
Attached is some Perl where it is simple to change whether or not pack is used.
use Tk; use Tk::DynaTabFrame; use strict; use warnings; my ($tabno, %frames, %label, %cp_wg, $raised_label); my $color = 'GREY'; my $raisecolor = 'WHITE'; my $side = 'nw'; my $mw = MainWindow->new(); my $frame_for_dynatab = $mw->Frame(-borderwidth => 4, -relief => 'rais +ed')->grid(-row => 0, -column => 0); my $dtf = $frame_for_dynatab->DynaTabFrame( -font => 'Arial 8', -raisecmd => \&raise_cb, -tabcolor => $color, -raisecolor => $raisecolor, -tabside => $side, -tabpadx => 3, -tabpady => 3, -tiptime => 600, -tipcolor => 'white' ) ->grid(-row => 0, -column => 0); $raised_label = $frame_for_dynatab->Label(-text => "")->grid(-row => 1 +, -column => 0); for($tabno = 1; $tabno <= 20; $tabno ++) { my $caption = "Caption $tabno"; # print "$caption\n"; $frames{$tabno} = $dtf->add( -caption => $caption, -tabtip => "Tip for $tabno", )->pack(); # ); $label{$tabno} = $frames{$tabno}->Label(-text => "Text in +$tabno Tabbed Frame", -width => 100)->grid(-row => 1, -column => 0); $cp_wg{$caption} = $frames{$tabno}; } sub raise_cb() { my ($current_tab, $current_tab_name, $lbr_str); $current_tab = $dtf->cget(-raised); $current_tab_name= $dtf->cget(-raised_name); $lbr_str = "current <$current_tab> name <$current_tab_name>"; $raised_label->configure (-text => $lbr_str); } MainLoop;

Replies are listed 'Best First'.
Re: DynaTabFrame 'Add' syntax query
by $self (Friar) on Aug 29, 2009 at 12:00 UTC

    in the dynatabframe code the ->pack() is already there so it's better not to call it again.

    Looking at the demo (e.g. inside zip on this page) it seems that when packing the dynatabframe itself the -fill => 'both' option may be necessary.

    With your grid approach you can get the same effect by adding -sticky => 'nsew' as a grid option.

    Either of these solved the problem for me.