#!/usr/bin/perl -w use strict; use Tk; my $main = MainWindow->new(); $main->minsize( qw(450 250) ); $main->title("Look! My first Perl/Tk window."); $main->configure(-background => 'Cyan' ); my $menu_bar = $main->Frame(-relief=>'groove', -borderwidth => 3, -background => 'purple', )->pack(-side =>'top', -fill=>'x'); my $file_mb = $menu_bar->Menubutton(-text=>'File', -background=>'purple', -activebackground=>'cyan', -foreground=>'white', )->pack(-side =>'left'); my $file_mb2 = $menu_bar->Menubutton(-text=>'Help', -background=>'purple', -activebackground=>'cyan', -foreground=>'white', )->pack(-side =>'left'); $file_mb->command(-label=>'Exit', -activebackground =>'magenta', -command=>sub{$main->destroy}); $file_mb->separator(); # Code to recurse the children of '$file_mb' # again - don't do this in real life. :) foreach ($file_mb->children) { print "$_\n"; $_->configure(-background => 'purple'); #Interestingly only Tk::Menu is found an it has no children... foreach ($_->children) { print "\t>$_\n"; if ($_->cget('-background')) { $_->configure(-background => 'purple'); } } } MainLoop();