Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

using Tk::FileSelect

by wmoran (Initiate)
on Nov 05, 2002 at 15:36 UTC ( #210477=perlquestion: print w/replies, xml ) Need Help??

wmoran has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to use Tk::FileSelect and I'm having problems getting a directory from it.

This app is basically a front end to dump/tar/mkisofs+cdrecord so the user has to be able to select a directory or a file.

The problem is when I select a directory in the box (for example, "/usr/local/*") I get it back from the select box twice (i.e. "/usr/local//usr/local/*") This obviously isn't what I want.

Before I write some sort of sub to correct the double directory, I wanted to see if possibly there were some extra options I should pass to the FileSelect to correct this? I'm calling it minimally now, meaning:

$fs = $mw->FileSelect(-directory => "/"); $directory = $fs->Show();

Replies are listed 'Best First'.
Re: using Tk::FileSelect
by strider corinth (Friar) on Nov 05, 2002 at 16:22 UTC
    The problem looks like it stems from the way Tk::FileSelect handles file masks, and its selection verifying feature. You aren't allowed (by default) to pick directories, just files. So when you select /usr/local/*, you're seeing odd results because you're not selecting the directory itself, but all of the files within it.

    If you add $fs->configure( -verify => [ '-e' ] ); after you create your selection dialog, it will switch the verification flag from '!-d' (don't select directories) to '-e' (select anything that exists). My test program returns just the directory name when that line is inserted.

    For more info, check the CPAN docs for Tk::FileSelect.
    --

    Love justice; desire mercy.
      That does it, thanks for the reply.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://210477]
Approved by Tanalis
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2020-01-20 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?