我已经看到很多关于使用 askopenfilename() 的帖子,但是一旦我选择了所述文件,我似乎仍然找不到任何东西可以帮助我在输入框中显示完整的文件路径。下面我已经包括了我离开的地方。
from tkinter import *
from tkinter.filedialog import askopenfilename
global a
def browse():
a = askopenfilename(title='select new file')
root = Tk()
a = StringVar()
l = Label(root, text="new file: ")
l.pack()
e = Entry(root, width=25, textvariable=a)
e.pack()
b = Button(root, text="Browse", command=browse)
b.pack()
root.mainloop()