来自tkinter import * window = Tk()
nor = {} ent = {}
对于范围内的i(10):de = IntVar()nac [i] = IntVar()
na=Checkbutton(window, text='%s' % (i), borderwidth=1,variable =
nac[i], onvalue = 1, offvalue = 0,command=lambda e=ent,
v=nac[i]:naccheck(e,v))
na.grid(row=i, column=0)
ent[i]=Entry(window,textvariable=de, state = DISABLED)
ent[i].grid(column=1,row=i,padx=20)
window.mainloop()
试试这个:
from tkinter import *
def entry():
ent[i].configure(state = NORMAL)
window=Tk()
nac = {}
ent = {}
for i in range(10):
de = IntVar()
nac[i]=IntVar()
na=Checkbutton(window, text='%s' % (i), borderwidth=1,variable = nac[i],
onvalue = 1, offvalue = 0,command=entry)
na.grid(row=i, column=0)
ent[i]=Entry(window,textvariable=de, state = DISABLED)
ent[i].grid(column=1,row=i,padx=20)
window.mainloop()