初学tkinter,想研究一下combobox,于是写了点代码想试一下,结果....
代码如下:
import tkinter as tk
from tkinter import ttk
def fn():
print(cbl_f.get())
window = tk.Tk()
window.geometry('600x450')
window.title('py --> exe')
winvalue = tk.StringVar()
cbl_f=ttk.Combobox(window,textvariable=winvalue, state='readonly')
cbl_f["values"]=("单个文件","多个文件")
cbl_f.bind("<<ComboboxSelected>>",fn)
cbl_f.place(x=1, y=430)
window.mainloop()
想要返回选中的内容,结果报错:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
TypeError: fn() takes 0 positional arguments but 1 was given
大神们,咋办?