【发布时间】:2021-09-30 09:16:41
【问题描述】:
我这里有这个功能。
def choose_file():
file = askopenfile(mode ='r', filetypes =[('xodr Files', '*.xodr')])
if file:
res = "selected:", file
else:
res = "file not selected"
return(res)
我有这个按钮来打开对话框并选择一个文件
e3=Button (scalF, text='Wählen Sie ein Dokument',font=('Bahnschrift SemiLight',12),command=choose_file, bg='blue')
e3.pack(side='top')
选择一个文件并关闭对话框后,我想在下面的标签中显示choose_file() 中定义的变量 res 的值
chosenFile = Label(scalF,text="I want to write here",font=('Bahnschrift SemiLight', 10))
chosenFile.pack(side='top')
你能解释一下如何从全局范围内读取变量res吗?
【问题讨论】: