I want to create Button and Entry(state=disabled) widgets with a for loop. The number of widgets to be created will be a runtime argument. What I want is that every time I click the button, the corresponding entry will become enabled(state="normal"). The problem in my code is that any button I click, it only affects the last entry widget. Is there anyway to fix this.? Here is my code:
from tkinter import *
class practice:
def __init__(self,root):
for w in range(5):
button=Button(root,text="submit",
command=lambda:self.enabling(entry1))
button.grid(row=w,column=0)
entry1=Entry(root, state="disabled")
entry1.grid(row=w,column=1)
def enabling(self,entryy):
entryy.config(state="normal")
root = Tk()
a = practice(root)
root.mainloop()