Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | # BrowseEntry, another example. |
2 | # | |
3 | # Chris Dean <ctdean@cogit.com> | |
4 | ||
5 | use strict; | |
6 | use Tk; | |
7 | use Tk::BrowseEntry; | |
8 | ||
9 | my $top = new MainWindow( -title => "BrowseEntry 2" ); | |
10 | main( $top ); | |
11 | MainLoop(); | |
12 | ||
13 | sub main { | |
14 | my( $top ) = @_; | |
15 | ||
16 | my @countries = qw( America Belize Canada Denmark Egypt Fruitopia ); | |
17 | my @states = qw( normal readonly disabled ); | |
18 | foreach my $i (0..$#states) { | |
19 | my $state = $states[$i]; | |
20 | my $var = $countries[$i]; | |
21 | my $f = $top->Frame->pack( qw/-side left/ ); | |
22 | my $be = $f->BrowseEntry( -variable => \$var, | |
23 | -choices => \@countries, | |
24 | -state => $state )->pack; | |
25 | if( $state eq "disabled" ) { | |
26 | $be->configure( -arrowimage => $f->Getimage( "balArrow" ) ) | |
27 | } | |
28 | foreach my $s (@states) { | |
29 | $f->Radiobutton( -text => $s, | |
30 | -value => $s, | |
31 | -variable => \$state, | |
32 | -command => sub { | |
33 | $be->configure( -state => $state ); } | |
34 | )->pack( qw/-anchor w/ ); | |
35 | } | |
36 | $f->Button( -text => "Print value", -command => sub { | |
37 | print "$var\n" } )->pack; | |
38 | } | |
39 | } |