# This demonstration script prompts the user to select a file.
# SCCS: @(#) filebox.tcl 1.3 97/03/02 16:22:36
-text
=> "Enter a file name in the entry box or click on the \"Browse\" buttons to select a file name using the file selection dialog.",
-title
=> 'File box Demonstration',
foreach my $i (qw(open save)) {
my $lab = $f->Label(-text
=> "Select a file to $i: ",
my $ent = $f->Entry(-width
=> 20);
my $but = $f->Button(-text
=> "Browse ...",
-command
=> sub { fileDialog
($TOP, $ent, $i)});
$lab->pack(-side
=> 'left');
$ent->pack(-side
=> 'left',-expand
=> 'yes', -fill
=> 'x');
$but->pack(-side
=> 'left');
$f->pack(-fill
=> 'x', -padx
=> '1c', -pady
=> 3);
my $cbf = $TOP->Frame->pack(-fill
=> 'x', -padx
=> '1c', -pady
=> 3);
-command
=> sub { local($^W
) = 0;
Tk
::FileSelect
->import('as_default');
# XXX remove cached dialogs
my $mw = $TOP->MainWindow;
delete $mw->{'tk_getOpenFile'};
delete $mw->{'tk_getSaveFile'};
})->pack(-side
=> 'left');
my $fdb = $cbf->Radiobutton
-command
=> sub { local($^W
) = 0;
Tk
::FBox
->import('as_default');
# XXX remove cached dialogs
my $mw = $TOP->MainWindow;
delete $mw->{'tk_getOpenFile'};
delete $mw->{'tk_getSaveFile'};
})->pack(-side
=> 'left');
# XXX Motif style file box not implemented
# unless (compare($tcl_platform{'platform'},'unix'))
# $w->{'.strict'} = $w->Checkbutton('Name','strict','-text',"Use Motif Style Dialog",'-variable','tk_strictMotif','-onvalue',1,'-offvalue',0);
# $w->{'.strict'}->pack('-anchor','c');
# Type names Extension(s) Mac File Type(s)
#---------------------------------------------------------
(["Text files", [qw
/.txt .doc/]],
["Text files", '', 'TEXT'],
["Perl Scripts", '.pl', 'TEXT'],
["C Source Files", ['.c', '.h']],
["All Source Files", [qw
/.tcl .c .h/]],
["Image Files", ['.jpeg', '.jpg']],
["Image Files", '', [qw
/GIFF JPEG/]],
if ($operation eq 'open') {
$file = $w->getOpenFile(-filetypes
=> \
@types);
$file = $w->getSaveFile(-filetypes
=> \
@types,
-initialfile
=> 'Untitled',
-defaultextension
=> '.txt');
if (defined $file and $file ne '') {