#!/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 }