Ask a Question related to PERL Miscellaneous, Design and Development.
-
Go Perl #1
FILE SELECTION DIALOG PROBLEM
I am using the following code to create file selection dialogs..But
apparently the Browse buttons do not seem to work.. i got this from
examples provided by typing widget. I changed a little to remove the
radio buttons and stuff, but i am not able to browse and select the
files. I will be glad if anyone can point the error and throw some
light on this.
Thanks very much.
use Tk;
$mw = MainWindow->new();
foreach my $i (qw(one two three four)) {
my $f = $mw->Frame;
my $lab = $f->Label(-text => "Select $i file to Open: ",
-anchor => 'e');
my $ent = $f->Entry(-width => 20);
my $but = $f->Button(-text => "Browse ...",
-command => sub { fileDialog($mw, $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);
}
sub filebox {
my $demo = shift;
(
-name => $demo,
-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.",
-iconname => 'filebox',
);
}
sub fileDialog {
my $w = shift;
my $ent = shift;
my $operation = shift;
my $types;
my $file;
@types =
(["Text files", '*.txt'],
["All files", '*']
);
if ($operation eq 'open') {
$file = $w->getOpenFile(-filetypes => \@types);
}
}
Go Perl Guest
-
Download a file without a dialog box
Hello: I'm tryng to download an image and showing it in an image control of a flex 2 or 3 application. In the FileIO example I get this fr = new... -
file open dialog
i know this is the 3d forum but i swear i have seen the answer to my question on this list before. is there a shockwave-safe file xtra or... -
File Dialog Xtras?
Hey all, doest anyone know of a Cross Platform (Windows/OSX) Xtra that allows you to open a file dialog where you can select multiple files? The... -
help with file dialog
"Go Perl" <puissant00@yahoo.com> wrote in message news:d3825316.0307290829.35a72bc3@posting.google.com... This is the subroutine that gets called... -
File Dialog Box
Does anyone know how do to get a file dialog box to work for Access 2000? I want to create a form that allows me to search for the file, put the... -
Bob Walton #2
Re: FILE SELECTION DIALOG PROBLEM
Go Perl wrote:
....> I am using the following code to create file selection dialogs..But
> apparently the Browse buttons do not seem to work.. i got this from
> examples provided by typing widget. I changed a little to remove the
> radio buttons and stuff, but i am not able to browse and select the
> files. I will be glad if anyone can point the error and throw some
> light on this.>
> use Tk;
> $mw = MainWindow->new();
>
> foreach my $i (qw(one two three four)) {
> my $f = $mw->Frame;
> my $lab = $f->Label(-text => "Select $i file to Open: ",
> -anchor => 'e');
> my $ent = $f->Entry(-width => 20);
> my $but = $f->Button(-text => "Browse ...",
> -command => sub { fileDialog($mw, $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);
> }
MainLoop; #is needed here
Your "browse" buttons work fine. The sub you are calling with the>
>
> sub filebox {
> my $demo = shift;
>
>
> (
> -name => $demo,
> -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.",
> -iconname => 'filebox',
> );
> }
>
> sub fileDialog {
> my $w = shift;
> my $ent = shift;
> my $operation = shift;
> my $types;
> my $file;
> @types =
> (["Text files", '*.txt'],
> ["All files", '*']
> );
> if ($operation eq 'open') {
> $file = $w->getOpenFile(-filetypes => \@types);
> }
>
> }
>
-command of each Button is not given a third argument of 'open',
however, so it appears as if the Button does nothing. If you change it
so the the third argument is 'open' instead of $i, then the file dialog
does appear. But then, you don't do anything with $file once you have
it, so your program needs lots more work.
And BTW, your example is missing a MainLoop; statement in the main program.
--
Bob Walton
Bob Walton Guest



Reply With Quote

