#!/usr/bin/perl -w
##########################################################
# textExample.pl
# Thomas Anastasio
# Created: November 25, 2001
# Current: November 25, 2001
##########################################################
use Tk; # bring in the Tk module
$topWin = MainWindow->new();
$topWin->configure(-title => 'Scale');
# Frames. These will be top and bottom of window
my $frame1 = $topWin->Frame();
my $frame2 = $topWin->Frame();
# Buttons in top frame.
my $b1 = $frame1->Button();
my $quitButton = $frame1->Button();
# Text widget in bottom frame.
my $text = $frame2->Text();
$b1->configure(-text => 'Clear',
-command => [ \&HandleClear, $text ]);
$quitButton->configure(-text => 'quit',
-bg => 'red',
-width => 5,
-height => 1,
-command => sub{exit} );
$text->configure(-height => 5, # 5 lines high
-background => 'white',
-foreground => 'black',
-width => 40,
-wrap => 'word',
-font =>
'-adobe-helvetica-bold-r-normal--0-120-75-75-p-63-iso8859-1');
$text->insert("end", "Type text into this window");
# Pack the frames in the top window
$frame1->pack(-side => 'top');
$frame2->pack(-side => 'top');
# Pack the widgets in the frames
$b1->pack(-side => 'left');
$quitButton->pack(-side => 'left');
$text->pack();
# Start the GUI infinite loop.
MainLoop();
sub HandleClear
{
my $text = $_[0];
$text->delete('1.0','end');
$text->insert("end", ">> ");
}
|
Updated: TAA 8:45pm Nov 25, 2001