Place

The place method allows one to place at some fixed location a widget within a window. The basic usage is
$widget->place( [ option => value ] );
For the use of place, one must specify the x and y coordinates of where in the window the widget is to be positioned; a window's coordinates start at (x, y) = (0, 0) in the upper left hand corner, with x increasing to the right and y increasing downwards.

Our basic previous example rewritten to use place is as follows.

#!perl
# file place1.pl
use Tk;
use strict;
my $mw = MainWindow->new;
$mw->title('Place Example');
my $title = $mw->Label(-text => "Example of using place \non several widgets");
my $cb1 = $mw->Checkbutton(-text => 'Checkbutton 1');
my $button = $mw->Button(-text => 'A Button');
my $label = $mw->Label(-text => 'A Label');
my $cb2 = $mw->Checkbutton(-text => 'Checkbutton 2');
my $exit = $mw->Button(-text => 'Exit',
                       -command => [$mw => 'destroy']);
$title->place(-x => 30, -y => 10);
$cb1->place(-x => 1, -y => 50);
$cb2->place(-x => 100, -y => 50);
$label->place(-x => 70, -y => 90);
$exit->place(-x => 70, -y => 120);
MainLoop;
which results in the following window:

Figure 2.9: An example of the use of place
Image place1

As discussed in the Tk documentation, available options to place are as follows.

Randy Kobes 2003-11-17