Hi experts, I am not a full programmer. I kind of do it for my needs. My request could be easy to do with Perl-Tk but I have no clue how to...

I have a notebook with Sheets added inside a foreach loop. Inside each tab I have Text area that displays log using fileevent. Works really well.

The window is launched and $log_display->insert('end', $_ ); works great.

I want to 'add' more tabs to this notebook dynamically from another job start if a condition is met.

Since the widgets are created already, I was looking for a function like 'get all opened mainwindow' and for the new job, I thought I could add the new tab to the handle.

My code skeleton looks like: my $window = Tk::MainWindow->new(); my $book = $window->NoteBook(); #geometry, pack, title etc @input=("corner1","corner2")#generated by another loop #other buttons frames etc foreach my $corner (@input) { $tab = $book->add("TAB $index", -label => "$corner"); $for_display=$tab->Scrolled('Text', )->pack(); #blah blah $CHILD = IO::Handle->new; open($CHILD, "$unix_command 2>&1 |"); $logWindow->fileevent($CHILD, 'readable', [\&callback,args]); } #then using sub callback will insert the $_ if sysread.
I want to update this mainwindow when I start the same pm file. My application request is not allowing me to 'add' using a button or so. I have to detect the previous window and add to it. hope I was clear! :-)

how to achieve this?


In reply to Perl-Tk Notebook - add a new tab to exisitng $mw by shankar.chandra

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.