in reply to REAL Dynamic tab creation/deletion in Tk::NoteBook.
#!/usr/bin/perl use Tk; use Tk::NoteBook; my $top = MainWindow->new( ); $top->geometry('300x300'); my $nb = $top->NoteBook()->pack(); add_tab(); $top->Button( -text => "Add Tab", -command => \&add_tab )->pack(); $top->Button( -text => "Delete Tab", -command => \&delete_tab )->pack( +); $top->Button( -text => "Delete second Tab", -command => \&delete_1tab +)->pack(); MainLoop(); sub delete_tab { $nb->delete($i--) } sub add_tab { $nb->add(++$i, -label => $i )->pack() } sub delete_1tab { # you can also pass in a page variable here if you want my @list = $nb->info('pages'); print "@list\n"; if( grep{ $_ eq 2 } @list) { $nb->delete(2) } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: REAL Dynamic tab creation/deletion in Tk::NoteBook.
by thefinn (Initiate) on Jul 19, 2008 at 14:58 UTC | |
by zentara (Cardinal) on Jul 19, 2008 at 18:41 UTC |