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

Hi friends, I want an initial name appears in the widget getSaveFile, but I have not been able to achieve that. Somebody could help me? The code I am trying is:
use Tk; $mw=MainWindow->new(-title=>'Test'); $mw->resizable(0,0); $resumen2=$mw->getSaveFile( -initialfile =>"test", -title =>"Anything", -initialdir => "./*.txt", -defaultextension=>'txt' ); print $resumen2;
I would hope the word "test" appears into the widget, but it didn't. I am using Perl 5.8.7 for windows. Thanks in advance Dorian Oria

Edited by Chady -- added code tags.

Replies are listed 'Best First'.
Re: Problems with initial file in getSaveFile
by GrandFather (Saint) on Sep 21, 2005 at 01:03 UTC

    Looks like a bug to me. -title works. -filetypes works. -defaultextension, -initialdir and -initialfile are broken.

    Update: I was using Perl 5.8.7 for Windows on XP sp2


    Perl is Huffman encoded by design.
Re: Problems with initial file in getSaveFile
by pg (Canon) on Sep 21, 2005 at 01:26 UTC

    It worked for me, "test" did show up in the file name field on the dialog box. I am using 5.8.4 and XP, don't know whether that matters.

    Unlike what GrandFather said, everything worked for me, the initial directory, initial file name, and also the default extention, which shows up in the returned file name from the getSaveFile() call.

Re: Problems with initial file in getSaveFile
by injunjoel (Priest) on Sep 21, 2005 at 00:29 UTC
    Greetings all,
    Im not sure if this helps but in reading the docs on Tk::FBox there is only mention of Unix/X11 support. Im not sure that this will give you what you want on Win32.
    From Tk::FBox docs:
    Tk::FBox is the dialog implementation behind the getOpenFile and getSaveFile method calls in the Unix/X11 world. As such, it supports all options for these methods and additionally:
    "I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo
Re: Problems with initial file in getSaveFile
by dorian (Novice) on Sep 21, 2005 at 13:25 UTC
    Hi everyone, thanks for your answers. I agreee with pg. In the Perl version 5.8.6 and before I could run the script. I think GrandFather is right, it must be a bug in this new release of Perl. Anyway, if somebody has had solved the problem, I really appreciate the help. Dorian Oria