我正在尝试使用函数将每个单独的复选框链接到特定的输入框。但我不知道如何命名每个单独的检查按钮。编码对我来说是新的,我迫切需要帮助......
尝试使用在线找到的功能,但只有最后一个输入框受到影响
from tkinter import *
#initialise intial window, root
root = Tk()
dishes = Text(root, cursor="arrow")
qty = Text(root, cursor="arrow")
dishes.pack(side=RIGHT)
qty.pack(side=LEFT)
#to display a entrybox each row
for i in range(10):
ent = Entry(root, width=3, state='disabled')
qty.window_create("100.0", window=ent)
qty.insert("end", "\n")
##to display a checkbutton each row
for key in range(10):
var = IntVar(value=0)
cb = Checkbutton(dishes, text="%d" % key,
variable=var, onvalue=1, offvalue=0)
dishes.window_create("end", window=cb)
dishes.insert("end", "\n")
root.mainloop()