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

旧城冷巷雨未停 提交于 2019-12-03 20:26:14

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',
);

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!