How do I allow a user to select a file?

前端 未结 1 1406
醉话见心
醉话见心 2021-01-14 14:45

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 sel

相关标签:
1条回答
  • 2021-01-14 15:41

    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.

    0 讨论(0)
提交回复
热议问题