试图制作一个带有“打开文件”按钮的图形用户界面。当我运行下面显示的代码时,“打开文件”对话框会立即打开,而不是当我按下按钮时。为什么?有没有一种不需要使用类的简单方法来解决这个问题?(我目前对课程一无所知,正在做一个时间紧迫的项目)
from tkinter import *
interface = Tk()
def openfile():
return filedialog.askopenfilename()
button = ttk.Button(interface, text = "Open", command = openfile())
button.grid(column = 1, row = 1)
interface.mainloop()
目前没有回答
相关问题 更多 >
编程相关推荐