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

I'm using Tk::FileDialog for file and directory selection.

I have a problem in MS Windows, the FileDialog window appears behind the parent window and is therefore partially or fully hidden. An annoyance to the user.

The script must run on both UNIX and MSWindows platforms. I chose Tk::FileDialog because it worked the best on both platforms. The FileDialog window works fine in UNIX (ie. it shows up on top).

Is there a better module to use that will work on both platforms?
Does anyone know of a configure setting that will force the FileDialog window to the top?

Sample code:
my $Dir = $main->Frame(....); my $DirDialog = $Dir->FileDialog(-Title=>'A title', -Create=>0, -SelDir=>1); my $DirDialog->configure(-FPat=>'*', -ShowAll=>'NO'); my $DirName = $DirDialog->Show(-Path => $APathName);

Replies are listed 'Best First'.
Re: Annoyance with Tk::FileDialog in MSWindows
by rbc (Curate) on Apr 09, 2002 at 17:11 UTC
    Hi mtr4cv,

    You might want to try something like this ...
    if ( $^0 eq $windows ) { $userFile = $top->getOpenFile ( ... ); } else { # do the way that's works already ... }
Re: Annoyance with Tk::FileDialog in MSWindows
by mtr4cv (Novice) on Apr 11, 2002 at 15:11 UTC
    I ended up switching to using getOpenFile and DirSelect on Windows. Still working on some of the quirks with the above two modules for UNIX (main complaint is they always open up in root "/"). If I can't get the UNIX issues solved, I'll use FileDialog for UNIX.

    I found a problem with FileDialog in windows which forced me to switch to getOpenFile & DirSelect. FileDialog does NOT handle spaces in directory names. If you have a space anywhere in your path, the file listing window will be empty.
Re: Annoyance with Tk::FileDialog in MSWindows
by {NULE} (Hermit) on Apr 09, 2002 at 22:38 UTC
    Hi mtr4cv,

    I do not have an easy answer for you. FileDialog ISA Toplevel and should take -takefocus => 1 as an argument. It appears not to. I tried some sample code on a win2k box and saw the problem you described. Looking at the module code it does not appear to handle focus like a typical module (using Toplevel) would.

    I think FileSelect works in a much more intuitive manner than FileDialog does. It looks decent enough and behaves like a typical popup (*not* verified on win2k). The added advantage is that FileSelect is a standard part of Tk so you won't annoy potential downloaders with 'yet another module to install syndrome'.

    Update: Confirmed - FileSelect works as expected in win2k (at least). I recommend you use it - have a peek at FileSelect.pm to see the available configuration options.

    Sorry I couldn't be of more help - I tried to bludgeon FileDialog into submission, but it wouldn't listen. Bad module! {g}
    {NULE}
    --
    http://www.nule.org