Existing module for file browser

J

John Black

Hi, I have some perl code that processes a file or files and I want an easy Windows familiar
way for the user to specify the filename. I.e. my users are not really into "command lines".

I have used Win32::GUI a little but I am looking for an off the shelf solution that someone
has hopefully done to allow the user to use the windows file browser or something like it to
traverse the directory tree, find their file and select it. This module would ideally just
return a scalar variable containing the filename with path and then my existing code can take
it from there. (extra credit to allow the user to select multiple filenames and have them
returned in an array...)

Does such a thing exist in the public domain? Thanks!

John Black
 
B

Bjoern Hoehrmann

* John Black wrote in comp.lang.perl.misc:
Hi, I have some perl code that processes a file or files and I want an easy Windows familiar
way for the user to specify the filename. I.e. my users are not really into "command lines".

I have used Win32::GUI a little but I am looking for an off the shelf solution that someone
has hopefully done to allow the user to use the windows file browser or something like it to
traverse the directory tree, find their file and select it. This module would ideally just
return a scalar variable containing the filename with path and then my existing code can take
it from there. (extra credit to allow the user to select multiple filenames and have them
returned in an array...)

Sounds like you want one of the Win32:: modules that expose a standard
function like `GetOpenFileName`, Win32::GUI among them; there probably
is nothing considerably more off-the-shelf.
 
D

Dr.Ruud

Hi, I have some perl code that processes a file or files and I want an easy Windows familiar
way for the user to specify the filename. I.e. my users are not really into "command lines".

I have used Win32::GUI a little but I am looking for an off the shelf solution that someone
has hopefully done to allow the user to use the windows file browser or something like it to
traverse the directory tree, find their file and select it. This module would ideally just
return a scalar variable containing the filename with path and then my existing code can take
it from there. (extra credit to allow the user to select multiple filenames and have them
returned in an array...)

Does such a thing exist in the public domain? Thanks!

Or tell them to use a specific extension on the file,
and configure your script to be the default opener for that extension.

Because then they can just doubleclick on the file's name, in their
favorite file browser, to let your script have it.

You can also implement drag-and-drop, such that if the user drops a
bunch of files on your icon, your script gets called.
 
K

Klaus

Hi, I have some perl code that processes a file or files and I want an easy Windows familiar
way for the user to specify the filename.  I.e. my users are not reallyinto "command lines".

I have used Win32::GUI a little but I am looking for an off the shelf solution that someone
has hopefully done to allow the user to use the windows file browser or something like it to
traverse the directory tree, find their file and select it.  This module would ideally just
return a scalar variable containing the filename with path and then my existing code can take
it from there.  (extra credit to allow the user to select multiple filenames and have them
returned in an array...)

That's the kind of thing the "Windows-standard-File-Explorer-right-
click-sendto-folder" is made for:

First you write a "hello.bat" file that encapsulates a small perl
prototype as follows:

hello.bat:
----------------------
@rem = '--*-Perl-*--
@echo off
perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
@rem ';
#!perl
use strict;
use warnings;
for my $file (@ARGV) {
print "File '$file' has been selected\n";
# ... do stuff with $file ...
}
__END__
:endofperl
pause
----------------------

Then you put the "hello.bat" file into your sendto-folder.

(on my Windows 7, the sendto-folder is under C:\Users\zzzz\AppData
\Roaming\Microsoft\Windows\SendTo\, you can use the start-icon on the
lower-left corner of your screen and type "shell:sendto" to find out
where the "sendto" folder is on your system...)

Once the "hello.bat" is in your "sendto" folder, just fire up your
File Explorer, any old directory will do, let's say you go straight to
your C:\ directory, you select 2 or 3 files and you right-click and
select sendto...

Under sendto, you will find (amongst other things) a menu "hello.bat"
-- go straight to that "hello.bat" and voilà: the names of the
selected files appear in a dos-box.

I hope this helps.
 
G

George Mpouras

what I do is to use one of the
"zenity" , "kdialog" or "zenity for windows"
some times I write a small vbs script for user input
 
J

John Black

Or tell them to use a specific extension on the file,
and configure your script to be the default opener for that extension.

Because then they can just doubleclick on the file's name, in their
favorite file browser, to let your script have it.

You can also implement drag-and-drop, such that if the user drops a
bunch of files on your icon, your script gets called.

Cool idea thanks. I actually thought of this but 1) I need to use files with standard
extensions like .csv and 2) I think the technology to select files with a browser within a
perl script will come in handy for future projects too.

John Black
 
J

John Black

* John Black wrote in comp.lang.perl.misc:

Sounds like you want one of the Win32:: modules that expose a standard
function like `GetOpenFileName`, Win32::GUI among them; there probably
is nothing considerably more off-the-shelf.

This looks promising. Thanks!

John Black
 
J

John Black

klaus03 said:
That's the kind of thing the "Windows-standard-File-Explorer-right-
click-sendto-folder" is made for:

First you write a "hello.bat" file that encapsulates a small perl
prototype as follows:

hello.bat:
----------------------
@rem = '--*-Perl-*--
@echo off
perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
@rem ';
#!perl
use strict;
use warnings;
for my $file (@ARGV) {
print "File '$file' has been selected\n";
# ... do stuff with $file ...
}
__END__
:endofperl
pause
----------------------

Then you put the "hello.bat" file into your sendto-folder.

(on my Windows 7, the sendto-folder is under C:\Users\zzzz\AppData
\Roaming\Microsoft\Windows\SendTo\, you can use the start-icon on the
lower-left corner of your screen and type "shell:sendto" to find out
where the "sendto" folder is on your system...)

Once the "hello.bat" is in your "sendto" folder, just fire up your
File Explorer, any old directory will do, let's say you go straight to
your C:\ directory, you select 2 or 3 files and you right-click and
select sendto...

Under sendto, you will find (amongst other things) a menu "hello.bat"
-- go straight to that "hello.bat" and voilà: the names of the
selected files appear in a dos-box.

I hope this helps.

I appreciate this idea but I think its a little kludgier than what I am looking for.

John Black
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top