When calling the
tkFileDialog.askopenfile()
method in tkinter, how do I set the default directory to the home directory of the user? Is there a way to do this independent of operating system, or is this something that the programmer has to deal with?
os.path.expanduser('~')
should expand it out for you on most OSs (windows,unix)...
In other words:
home = os.path.expanduser('~')
f = tkFileDialog.askopenfile(initialdir = home)