in reply to Tk::NoteBook issue with creating tabs under a menu
#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::NoteBook; my %nbframes; my $top = MainWindow->new; $top->geometry("300x300"); my $menu = $top->Menu( -type => 'menubar' ); $top->configure( -menu => $menu ); $menu->Cascade( -label => '~Selections', -tearoff => 1, -menuitems => [ [ Button => 'dir', -command => [ \&addtab, 'dir' ] ], [ Button => 'time', -command => [ \&addtab, 'time' ] ], [ Button => 'ls', -command => [ \&addtab, 'ls' ] ], ], ); my $nb = $top->NoteBook->pack(qw/-side top -fill both -expand 1/); MainLoop; sub addtab { my $choice = shift; print $choice, "\n"; $nbframes{$choice}{'frame'} = $nb->add($choice, -label => $choice, -raisecmd => sub{ $top->update; }, -createcmd => sub{ $top->update; }, ); $nbframes{$choice}{'text'} = $nbframes{$choice}{'frame'}->Scrolled('Text',-bg=>'white')->pack( +); $nbframes{$choice}{'text'}->insert('end',time); $nbframes{$choice}{'text'}->focus(); $nb->Resize; #bug workaround }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tk::NoteBook issue with creating tabs under a menu
by thefinn (Initiate) on Jul 16, 2008 at 06:45 UTC | |
by Anonymous Monk on Jul 16, 2008 at 07:44 UTC |