#!/usr/bin/perl -w use strict; use Tk; use Tk::NoteBook; my $MW = MainWindow->new(); my $note = $MW->Label(-font=>'courier-12',-text=> "F1-4 presents/withdraws the notebook windows.")->pack(); my (@VW, @NB, %pg, %txt); foreach (0..3) { my $title = eval("$_+1"); $VW[$_] = $MW->Toplevel(-title=>"$title"); $VW[$_]->state('withdrawn'); $NB[$_] = $VW[$_]->NoteBook()->pack(); foreach my $L ("A","B","C","D") { my $name = "$L-$title"; $pg{$name} = $NB[$_]->add($name,-label=>'empty'); } } foreach (keys %pg) {$txt{$_} = $pg{$_}->Text()->pack()} # this version causes a seg fault: #foreach (keys %pg) {$txt{$_} = $pg{$_}->Text(-font=>"courier-12")->pack()} $MW->bind('all',""=>sub{toggle(0)}); $MW->bind('all',""=>sub{toggle(1)}); $MW->bind('all',""=>sub{toggle(2)}); $MW->bind('all',""=>sub{toggle(3)}); MainLoop;################## sub toggle { my $n = "@_"; my $state = $VW[$n]->state(); my $newstate = ($state eq 'withdrawn') ? 'normal' : 'withdrawn'; $VW[$n]->state("$newstate"); }