#!/usr/local/bin/perl use strict; use warnings; use Tk; my $mw = MainWindow->new(-title=>'Menubackground'); $mw->optionAdd("*tearOff", "false"); #tearoff line global entfernen # build menu my $mb = $mw->Frame (-relief=>'ridge',-bd=>3)->pack(-fill=>'x'); my $m_file = $mb->Menubutton(-text => 'File')->pack(-side=>'left'); my $m_edit = $mb->Menubutton(Name=>'name1', -text =>'Edit')->pack(-side=>'left'); # Einen Namen für das widget vergeben: name1 $m_edit->optionAdd("*name1*background", "skyblue"); # Attribut background neu setzen für name1 my $m_help = $mb->Menubutton(-text => 'Help')->pack(-side=>'right'); my $label=$mw->Label(-text=>'My Application', -width=>80, -height=>15)->pack; my $close_button = $mw->Button(-text => 'Close',-background=>'gray',-command => sub{$mw->destroy})->pack(-fill=>'x'); #fill the menu $m_file->command(-label => "Load", -command => sub{return}); $m_file->command(-label => "Save", -command => sub{return}); $m_file->separator(); $m_file->command(-label => "Exit", -foreground=>"blue", -command => sub{$mw->destroy}); $m_edit->command(-label => "Edit File1", -state => 'normal', -command => sub{return}); $m_edit->command(-label => "Edit File2", -state => 'normal', -command => sub{return}); $m_edit->separator(); $m_edit->command(-label => "Edit Picture1", -state => 'normal', -command => sub{return}); $m_edit->command(-label => "Edit Picture2", -state => 'normal', -command => sub{return}); $m_edit->separator(); $m_edit->command(-label => "Edit nothing", -state => 'normal', -command => sub{return}); $m_help->command(-label => "Help 1", -state => 'normal', -bg=>'red', -command => sub{return}); $m_help->separator(); $m_help->command(-label => "Help 2", -state => 'disabled', -command => sub{return}); MainLoop;