Choosing a file in Python3

前端 未结 3 1441
我寻月下人不归
我寻月下人不归 2021-02-05 14:08

Where is the tkFileDialog module in Python 3? The question Choosing a file in Python with simple Dialog references the module using:

from Tkinter import Tk
from          


        
3条回答
  •  感情败类
    2021-02-05 14:46

    You need to import filedialog first, you can do it as follows:

    from  tkinter import *
    from tkinter import filedialog
    
    root = Tk()
    
    root.filename =  filedialog.askopenfilename(initialdir = "/", title = "Select file")
    print (root.filename)
    
    root.mainloop()
    

提交回复
热议问题