in reply to Re: TK: adding notebook tabs dynamically
in thread TK: adding notebook tabs dynamically

Dynatabframe sounds great.

I am having trouble getting it to work (XP, activestate).

Am I / how am I using it wrong? Thanks for the help!

use strict; use Tk; use Tk::DynaTabFrame; my @tab; my $top = MainWindow->new(); my $nb = $top->DynaTabFrame; &add_tab() for 1 .. 6; $nb->pack; MainLoop(); my $i = 0; sub add_tab { $i++; print "adding tab $i\n"; $tab[$i] = $nb->add( -caption => 'Tab label' . $i, -tabcolor => 'black', ); $tab[$i]->Label( -text => 'dsdss' ); }

Replies are listed 'Best First'.
Re^3: TK: adding notebook tabs dynamically
by zentara (Cardinal) on Oct 11, 2004 at 16:17 UTC
    You have a really bad placement of your my $i = 0 line. But the reason your code dosn't work is you need to pack in the sub.
    #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::DynaTabFrame; my @tab; my $top = MainWindow->new(); my $nb = $top->DynaTabFrame->pack; my $i = 0; for(1..6){ &add_tab()}; MainLoop(); sub add_tab { $i++; print "adding tab $i\n"; $tab[$i] = $nb->add( -caption => 'Tab label' . $i, -tabcolor => 'black', )->pack; $tab[$i]->Label( -text => 'dsdss' )->pack; }

    I'm not really a human, but I play one on earth. flash japh
Re^3: TK: adding notebook tabs dynamically
by aquarium (Curate) on Oct 11, 2004 at 10:47 UTC
    Personally i have found tixnotebook much easier to use. i had similar/same problem with update of the notebook using tknotebook. in tixnotebook you can also color the background of each tab, have soft or sharp corners etc.