user1104854
user1104854

Reputation: 2167

Selecting directory's path with tkinter

I'm trying to get the full path of a directory using Tkinter, but only the directory name is being displayed.

For example when I select "C:\Python27\Doc", instead of the full path being displayed, only "Doc" displays.

class Actions:

    def openfile(self): #open the file  
        directory = tkFileDialog.askdirectory()
        print(directory)


    def body(self):
        Label (text='Please select a directory').pack(side=TOP,padx=10,pady=10)

I found this http://tkinter.unpythonic.net/wiki/tkFileDialog , but unless I'm misunderstanding it, I don't see anything for the full path.

Upvotes: 2

Views: 16245

Answers (1)

mgilson
mgilson

Reputation: 309891

Have you tried the initialdir keyword? e.g. tkFileDialog.askdirectory(initialdir='.'). What do you get then?

Upvotes: 6

Related Questions