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

Hi
I want to make a perl tk application with notebook. Let us consider the notebook pages will be dynamically created. Let us also consider that in a given instance Notebook has 3 pages and in each page I pack a
Tk::Text widget to view some text.

Is there any way so that I can close any of the notebook page when I am done ? Just like the way we do in Firefox or other browsers by closing a tab. Currently it closes the entire Notebook application. But I want to open or close a page according to my need.

Thanks.

Replies are listed 'Best First'.
Re: advanced perl tk widget than notebook
by Anonymous Monk on May 30, 2013 at 17:39 UTC

    You may want to look at "forget" and/or "destroy" for your page widgets.

    For help you should show some code that does what you are hinting at instead of just trying to get monks to imagine what you might mean.

      I am giving this code as example. Just consider that I will passing the number of pages I want in the notebook as command line argument.

      In this example, I am creating 3 pages by a foreach loop. How can I close any of them and again add one more according to my need.

      my $mw = MainWindow->new; my $noteframe = $mw->Frame(); my $book = $noteframe->NoteBook()->grid(-sticky=>'nsew')->pack(-expand + => 1, -fill => 'both'); my $page; foreach my $i (1 .. 3) { my $page = $book->add("$i", -label => "page_$i"); my $text = $page->Scrolled('Text', -scrollbars => 'e', -background => #efefef' )->pack(-fill => 'both', -expand=>1); $text->insert('end', "this is page $i"); } $noteframe->pack(-expand => 1, -fill => 'both', -side => 'top'); MainLoop;
Re: advanced perl tk widget than notebook
by Anonymous Monk on May 30, 2013 at 18:40 UTC