TK Directory question

Hello,

I am working on a GUI that allows the user to select a file to work on.
I am using Tk.getOpenFile to do this. I would like the application to
‘remember’ the file path from the last time they selected a file, so
that the user does not have to browse to the same location over and
over. I cannot find any info on how to do this.

Any help would be greatly appreciated. Thanks.

Harry

__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4196 (20090629) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

Hi,
a way is

  1. memorize into a var the last directory:

file = Tk.getOpenFile
@last_dir = File.dirname(file) if !file.nil?

  1. use the option ‘initialdir’ of Tk.getOpenFile

file = Tk.getOpenFile(‘initialdir’=>@last_dir)

Antonio

Harry T. wrote:

Hello,

I am working on a GUI that allows the user to select a file to work on.
I am using Tk.getOpenFile to do this. I would like the application to
‘remember’ the file path from the last time they selected a file, so
that the user does not have to browse to the same location over and
over. I cannot find any info on how to do this.

Any help would be greatly appreciated. Thanks.

Harry

__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4196 (20090629) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

Cool! Thank you very much!

Harry

----- Original Message -----
From: “Antonio G.” [email protected]
To: “ruby-talk ML” [email protected]
Sent: Monday, June 29, 2009 5:01 PM
Subject: Re: TK Directory question

file = Tk.getOpenFile(‘initialdir’=>@last_dir)

that the user does not have to browse to the same location over and
The message was checked by ESET NOD32 Antivirus.

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4199 (20090630) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com