#!/Perl/bin/perl
use strict;
use Tk;
use Tk::Menu;
my $mw = Tk::MainWindow->new();
my $var = 1;
my $menuitems = [
[Cascade => "~Datei", -menuitems =>
[
[Button => "~Neu", -command => sub{ return 1; }],
[Separator => ""],
[Button => "~Öffnen", -command => sub{ return 1; }],
[Button => "~Sichern", -command => sub{ return 1; }],
[Checkbutton => "~checkbox", -command => sub{ return 1; }, -variable => \$var,],
],
],
];
my $menu = $mw->Menu(-menuitems => $menuitems);
$mw->configure(-menu => $menu);
$mw->Button(
-text=>'Knopf',
-command => sub{
if( $var == 1 ) {
$var = 0;
}else{
$var = 1;
}
},
)->pack();
$mw->Label(-textvariable => \$var)->pack();
MainLoop;