tkFileDialog.askopenfilename()

R

rahulnag22

Hi,
When I call tkFileDialog.askopenfilename() , the dialog box opens with
the current directory as the default directory. Is it possible to open
the dialog box with a directory other than the current directory. Can
we pass in a user defined starting directory.
Thanks
Rahul
 
J

John McMonagle

Hi,
When I call tkFileDialog.askopenfilename() , the dialog box opens with
the current directory as the default directory. Is it possible to open
the dialog box with a directory other than the current directory. Can
we pass in a user defined starting directory.
Thanks
Rahul

tkFileDialog.askopenfilename() uses the tk command tk_getOpenFile, the
documentation for which is at:

http://www.tcl.tk/man/tcl8.4/TkCmd/getOpenFile.htm

Regards,

John
 
K

Kevin Walzer

Hi,
When I call tkFileDialog.askopenfilename() , the dialog box opens with
the current directory as the default directory. Is it possible to open
the dialog box with a directory other than the current directory. Can
we pass in a user defined starting directory.
Thanks
Rahul

Use the "initialdir" flag:

filename = askopenfilename(title="Open File",
initialdir=(os.path.expanduser('~/'))

HTH,
Kevin
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top