in reply to Re^2: Directory and file selection with PERL/Tk
in thread Directory and file selection with PERL/Tk

Hi elef. I'm trying to do something similar. I have a program that opens a directory and selects one of the subdirectories. However, I can't get it to create a new subdirectory if necessary. I tried typing over the name of the lowest subdirectory as you suggested, but that didn't work.

Did you ever find a solution? If not, would you please re-explain how to create a new subdirectory using the chooseDirectory widget? Thanks.

  • Comment on Re^3: Directory and file selection with PERL/Tk

Replies are listed 'Best First'.
Re^4: Directory and file selection with PERL/Tk
by elef (Friar) on Jun 13, 2013 at 12:02 UTC
    No, I'm still using this ugly and clumsy widget... I don't think there's an easily available better option.
    As far as creating a new subdirectory, the chooseDirectory returns a path, you create the directory. Parts of my code look something like this:
    my $folder; # in real code this is triggered by a button press $folder = $mw->chooseDirectory( -initialdir => '~', -title => 'Choo +se a folder',); # triggered after user made its folder choice # almost certainly won't work if user enters a multi-level folder stru +cture if (!-d "$folder") { print "\nCreating $folder"; mkdir "$folder" or abort("Can't create folder $folder: $! at line +" . __LINE__); # abort sub is my own code, use die if needed }