3

How do I open folder selection dialog in Perl?

brian d foy
  • 129,424
  • 31
  • 207
  • 592
Greg
  • 41
  • 1
  • 2

3 Answers3

7

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',
);
Adam Bellaire
  • 108,003
  • 19
  • 148
  • 163
7

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.

ephemient
  • 198,619
  • 38
  • 280
  • 391
3

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

Ether
  • 53,118
  • 13
  • 86
  • 159