#!/usr/local/bin/perl -w use 5.005; use Tk; use Tk::widgets qw/Dialog/; use subs qw/build_menubar fini/; use vars qw/$MW $VERSION/; use strict; $MW = MainWindow->new(); $MW->geometry('640x100'); my $menubar = build_menubar; my $Body = $MW->Frame(-background => 'cyan')->pack( -expand => 1, -fill => 'both', ); MainLoop; sub build_menubar { my $menubar = $MW->Menu; my $file = $menubar->cascade(-label => '~File'); $MW->configure(-menu => $menubar); $file->command(-label => "Print Text", -command => \&PrintText); $file->command(-label => "Quit", -command => \&fini); return $menubar; } sub PrintText{ my $lbl = $Body->Label( -text => "This is new text", -background => 'red', #-width => '100', # This would be 100 _characters_ #-height => '100', # And this 100 _lines_ )->pack( -fill => 'both', -expand => 1, ); } sub fini { exit; }