TK Directory question

H

Harry Truax

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
 
A

Antonio Galeone

Hi,
a way is

1) memorize into a var the last directory:

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

2) use the option 'initialdir' of Tk.getOpenFile

file = Tk.getOpenFile('initialdir'=>@last_dir)


Antonio
 
H

Harry Truax

Cool! Thank you very much!

Harry


----- Original Message -----
From: "Antonio Galeone" <[email protected]>
To: "ruby-talk ML" <[email protected]>
Sent: Monday, June 29, 2009 5:01 PM
Subject: Re: TK Directory question

Hi,
a way is

1) memorize into a var the last directory:

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

2) use the option 'initialdir' of Tk.getOpenFile

file = Tk.getOpenFile('initialdir'=>@last_dir)


Antonio



--
Posted via http://www.ruby-forum.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


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

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,174
Messages
2,570,941
Members
47,476
Latest member
blackwatermelon

Latest Threads

Top