summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/Tk/demos/widget_lib/form.pl
blob: bd60ef91475b07ea3f975d38644af71db8a1c2c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# form.pl

use vars qw/$TOP/;

sub form {

    # Create a top-level window that displays a bunch of entries with
    # tabs set up to move between them.

    my($demo) = @_;
    $TOP = $MW->WidgetDemo(
        -name     => $demo,
        -text     => 'This window contains a simple form where you can type in the various entries and use tabs to move circularly between the entries.',
        -title    => 'Form Demonstration',
        -iconname => 'form',
    );
    my $f = $TOP->Frame->pack(-fill => 'both');
    my $row = 0;
    foreach ('Name:', 'Address:', '', '', 'Phone:') {
	my $e = $f->Entry(qw/-relief sunken -width 40/);
	my $l = $f->Label(-text => $_, -anchor => 'e', -justify => 'right');
        $l->grid(-row => $row, -column => 0, -sticky => 'e');
        $e->grid(-row => $row++, -column => 1,-sticky => 'ew');
        $f->gridRowconfigure(1,-weight => 1);
	$e->focus if $_ eq 'Name:';
    }
    $TOP->bind('<Return>' => [$TOP => 'destroy']);

} # end form

1;