Thread Hintergrundfarbe vom Separtor im Menue
(4 answers)
Opened by perln00b at 2010-04-14 21:42
Ok...es geht noch etwas besser.
Wenn man sich perldoc Tk::options ansieht, erfährt man, daß die option database auch für einzelne widgets verändert werden kann. Wir grenzen das lustige Himmelblau dann nun mal weiter ein: (nur Zeile 12 und 13 sind wichtig. Der Rest ist zum spielen :) Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 #!/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; Damit erstrahlt nur noch das Edit Menu in himmlischem blau, während alle anderen widgets immer noch ihre default Farbe haben. Leider können anscheinend weder menu command noch separator etwas mit dem 'Name=>' switch anfangen. |