Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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


In reply to TK: adding notebook tabs dynamically by water

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-04-20 01:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found