blob: 5062afa0fad165080cfa5d0a91ac158fd6b5cf6c (
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
32
33
34
35
36
37
38
39
|
# This demonstration script prompts the user to select a directory.
use vars qw/$TOP/;
sub choosedir {
my $demo = shift;
$TOP = $MW->WidgetDemo
(
-name => $demo,
-text => "Enter a directory name in the entry box or click on the \"Browse\" buttons to select a directory name using the directory selection dialog.",
-title => 'Choose Directory Demonstration',
-iconname => 'choosedir',
);
{
my $f = $TOP->Frame;
my $lab = $f->Label(-text => "Select a directory to open: ",
-anchor => 'e');
my $ent = $f->Entry(-width => 20);
my $but = $f->Button(-text => "Browse ...",
-command => sub { dirDialog($TOP, $ent)});
$lab->pack(-side => 'left');
$ent->pack(-side => 'left',-expand => 'yes', -fill => 'x');
$but->pack(-side => 'left');
$f->pack(-fill => 'x', -padx => '1c', -pady => 3);
}
}
sub dirDialog {
my $w = shift;
my $ent = shift;
my $dir;
$dir = $w->chooseDirectory;
if (defined $dir and $dir ne '') {
$ent->delete(0, 'end');
$ent->insert(0, $dir);
$ent->xview('end');
}
}
|