|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
代码如下:
from tkinter import *
root = Tk()
def callback():
fileName = filedialog.askopenfilename(filetypes=[('PNG','.png'),('GIF','gif'),\
('JPG','.jpg'),('Python','.py')])
print(fileName)
Button(root,text='打开文件',command=callback).pack()
mainloop()
报错为:
Exception in Tkinter callback
Traceback (most recent call last):
File "D:\Python installation site\lib\tkinter\__init__.py", line 1699, in __call__
return self.func(*args)
File "D:/Python installation site/学习/077/l2.py", line 6, in callback
fileName = filedialog.askopenfilename(filetypes=[('PNG','.png'),('GIF','gif'),\
NameError: name 'filedialog' is not defined |
|