http://qs1969.pair.com?node_id=398074

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

Thanks everyone for all the Tk help.

I'm trying to add tabs to a notebook dynamically while the program is running, after MainLoop has started.

# silly toy example use strict; use Tk; use Tk::NoteBook; my $i=0; my $top = MainWindow->new( -title => 'client', ); my $nb = $top->NoteBook(); $top->repeat(200, \&add_tab); &add_tab() for 1 .. 20; MainLoop(); sub add_tab { exit if $i>50; $i++; print "adding tab $i\n"; my $tab = $nb->add($i, -label => $i ); $nb->pack; }
Here, the first 20 tabs are added fine, as MainLoop hasn't started yet, but the later tabs don't show up.

Without destroying and rebuilding the entire top window, how can I add a tab to a notebook after MainLoop has started?

Thanks!

water

UPDATE:
Thought I could solve the problem by preallocating a set of tabs for later use. Sure, but after MainLoop has started, if I change the options on the preallocated tab, those changes don't seem to be visible. So this preallocation scheme (as least as I implemented it) does not work. Suggestions, wise monks?

Considered: kelan dup of 398068
Unconsidered: ysth enough keep votes, positive rep - Keep/Edit/Delete: 2/2/20