How do I present an open folder selection dialog in Perl?

3.5k views Asked by At

How do I open folder selection dialog in Perl?

3

There are 3 answers

0
Ether On

You may want to check out the GUI bindings in wxPerl.

0
Adam Bellaire On

Depends on the GUI system you're using, and perhaps the platform. For example, on Windows and using Win32::GUI, you can use GetOpenFileName:

# $main is your main window...
$my_file = $main->GetOpenFileName(
    -title => 'Select a file...',
    -file => 'default.file',
);
0
ephemient On

Most portable (at least compared to others):

use Tk;
my $dir = Tk::MainWindow->new->chooseDirectory;

Of course, if you're actually using Tk in the rest of your program, you should call chooseDirectory on a proper parent widget instead of the one constructed and destructed here.