June 2002
Beginner
759 pages
80h 42m
English
Creating widgets and determining how to display them are
done with separate commands. You can create a widget with one of the
widget creation methods (such as Button, Canvas, etc.), but you display them using a
geometry manager. The three geometry managers are pack, grid, place, and form. pack is by far the most commonly
used.
You can either pack a widget as you create it or create the widget object and pack it separately. For example, the previous “Hello World” example might have read:
#!/usr/bin/perl -w
use Tk;
my $mw = MainWindow->new;
$button = $mw->Button(-text => "Hello World!", -command =>sub{exit});
$button->pack;
MainLoop;