By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 906 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

tkFileDialog.askopenfilename()

P: n/a
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

May 15 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
ra********@yahoo.com wrote:
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
May 15 '07 #2

P: n/a
ra********@yahoo.com wrote:
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
--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
May 15 '07 #3

P: n/a
look at "Basic Tkinter dialogs" from python cookbook at

http://aspn.activestate.com/ASPN/Coo.../Recipe/438123

May 16 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.