I have a tkinter window that am creating labels and entry widgets based on a list made by a database query.
I need to use the values entered in the entry widgets to create a new list to put into another database.
The list from the database has a variable count.
I use a loop to create the labels and entry widgets but can't work out how to name the entry widgets to be able to put the entries into a usable list. Ideally it will have the e.get
from the original query and the list tied to each of the entries.
Heres what i have so far.
#Create frame for Size inputs and labels
sizes_frame = tk.Frame(p,bg='yellow')
sizes_frame.grid(row=2,column=1)
connection = sqlite3.connect('productdata.db')
pro = connection.cursor()
pro.execute("SELECT Size FROM Products WHERE ColourCode = ?", (e.get(),))
connection.commit()
Sizes = pro.fetchall()
keys = Sizes
otherkeys = Sizes
count = 0
othercount = 0
labels=[]
otherlabels=[]
for j,l in enumerate(labels):
l.config(text=str(keys[j])+str(j))
for key in keys:
labels.append(Label(sizes_frame,text=key,font=('Helvatical bold',10)))
if count <10:
labels[count].grid(row = count, column = 1, padx=5, pady= 5)
count+=1
else:
labels[count].grid(row = count-10, column = 3, padx=5, pady= 5)
count += 1
for j,l in enumerate(otherlabels):
l.config(text=str(otherkeys[j])+str(j))
for otherkey in otherkeys:
otherlabels.append(Entry(sizes_frame,width= 6))
if othercount<10:
otherlabels[othercount].grid(row = othercount, column = 2, padx=5, pady= 5)
othercount += 1
else:
otherlabels[othercount].grid(row = othercount-10, column = 4, padx=5, pady= 5)
othercount += 1