Reputation: 125
Right now, I have this line in my code to hard-code the directory path
dir_path = '/home/user/pywork'
but I would rather let the user select it herself using a construct similar to R's scan(choose.files())
.
How do I go about it?
Thanks,
Upvotes: 3
Views: 12741
Reputation: 60944
One option I found after a quick google (python open directory dialog box
) is to use TKinter
:
import Tkinter, tkFileDialog
root = Tkinter.Tk()
dirname = tkFileDialog.askdirectory(parent=root, initialdir="/",
title='Please select a directory')
I found the information here.
Upvotes: 8