Newbie question: how to browse for a file in Tk?

J

James Calivar

Hello all,

I'm taking my first stab at writing a Tk interface for a Perl script that I
have developed. The existing Perl script reads configuration parameters
from a separate .ini file, and uses those values to do its thing while
running. Some of these config params are pathnames and filenames on the
system that the script is running on. What I'd like to be able to do is to
have the user be able to browse their filesystem using the mouse, and select
items that way. However, in looking through "Learning Perl/Tk," I didn't
immediately see anything that would allow me to do it, so I'm wondering if
someone here could give me an idea on how such a task is accomplished in
Perl/Tk.

Incidentally, this script is running on a Win32 platform (XP Pro) and I've
got ActiveState 5.8.4 installed.

Thanks for any help,

James
 
A

Anno Siegel

[...]
system that the script is running on. What I'd like to be able to do is to
have the user be able to browse their filesystem using the mouse, and select
items that way.

Do a CPAN search for the keywords "Tk" and "file".

Anno
 
J

James Calivar

Anno Siegel said:
[...]
system that the script is running on. What I'd like to be able to do is to
have the user be able to browse their filesystem using the mouse, and select
items that way.

Do a CPAN search for the keywords "Tk" and "file".

Anno

Anno,

Thanks for the tip. Alright - I've used ppm to download a module called
"Tk-FileDialog". But when I try to run the test script located at
http://cpan.uwinnipeg.ca/htdocs/Tk-FileDialog/Tk/FileDialog.html, I get the
following:

c:\>perl test.pl
can't make ".filedialog" its own master at C:/Perl/site/lib/Tk/Submethods.pm
line 37.
at C:/Perl/site/lib/Tk/FileDialog.pm line 470

Any idea what's wrong?

Thanks,

James
 
A

Ala Qumsieh

James said:
Hello all,

I'm taking my first stab at writing a Tk interface for a Perl script that I
have developed. The existing Perl script reads configuration parameters
from a separate .ini file, and uses those values to do its thing while
running. Some of these config params are pathnames and filenames on the
system that the script is running on. What I'd like to be able to do is to
have the user be able to browse their filesystem using the mouse, and select
items that way. However, in looking through "Learning Perl/Tk," I didn't
immediately see anything that would allow me to do it, so I'm wondering if
someone here could give me an idea on how such a task is accomplished in
Perl/Tk.

You need to use getOpenFile:

$top->getOpenFile(options);

check out the docs for Tk::getOpenFile for more info.

--Ala
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top