I wrote a programs that creates labels and entry widgets with a for loop. I want to save each entry widget in an array and than access each entry widget separately (for this example I want to put the word 'apple' in each entry widget.
this is my code:
import tkinter as tk
fields = 'last name', 'first name', 'job', 'state'
def makeform (root, fields):
frame1 = tk.frame(root)
frame1.pack()
entries = []
for I in range[0,4]
lab = tk.Label(frame1,text=fields[I]).grid(row=I, column=0)
ent = tk.Entry(frame1).grid(row=I, column=1)
entries.append((field[I],ent))
return entries
if _name_=="_main_":
root=tk.Tk()
ents=makeform(root, fields)
for ent in ents:
print (ents)
ent[1].delete(0, END)
ent[1].insert(0, "apple")
root.mainloop
and getting a 'attributeError: Nonetype object has no attribute 'delete'' and the 'print(ent[1])' command prints out none.
what am I missing? how do I save the entry widget in an array (their location?)
thank you