my $mw = MainWindow->new(-title=>"Test"); my $toplevel = $mw->toplevel; my $n = 'Neu'; my $o = 'Öffnen..'; my $s = 'Speichern'; my $sp = 'Speichern unter...'; my $b = 'Beenden'; our $menubar; Menu($n,$o,$s,$sp,$b); sub Menu{ my $n = shift; my $o = shift; my $s = shift; my $sp = shift; my $b = shift; $menubar = $toplevel->Menu(-type => 'menubar'); $toplevel->configure(-menu => $menubar); my $datei = $menubar->cascade(-label => '~Datei', -tearoff => 0); $datei->command(-label => "$n", -command => \&neu); $datei->command(-label => "$o", -command => \&open); $datei->command(-label => "$s", -command => \&speichern); $datei->command(-label => "$sp", -command => \&speichernunter); $datei->separator(); $datei->command(-label => "$b", -command => [$mw=>'destroy']); } $mw->Button(-text=>'clear',-command => sub {&chance} )->pack; MainLoop; sub chance { $menubar->destroy; my $n = 'new'; my $o = 'open'; my $s = 'save'; my $sp = 'save as'; my $b = 'close'; Menu($n,$o,$s,$sp,$b); }