Reputation: 23
In its current state I have created two lists, NameValues
and AgeValues
which contain the values written into a series of generated entry boxes when a button is clicked. I now need to insert them into a sqlite table. Before I can do the query however I am having problems assigning all the values to the variables Name
and Age
.
My problem is that if there are 2 entry boxes created for each variable and the values are submitted the program will only get the values in the last set of entry boxes, retrieving only half the data.
This is the code to fetch the data:
NameValues = []
AgeValues = []
def Insert(self):
for i in range(len(self.NameValues)):
Name = (self.NameValues[i].get())
for i in range(len(self.AgeValues)):
Age = (self.AgeValues[i].get())
Code = self.MemberCode.get()
print (Age)
I am printing the age as a test to see what values are stored in the variables and only the last value is being entered.
Upvotes: 1
Views: 1309
Reputation: 82765
You need to have Name & Age
as a list. I have used list comprehension
to assign all value to Name
and Age
list.
Ex:
NameValues = []
AgeValues = []
def Insert(self):
Name = [self.NameValues[i].get() for i in range(len(self.NameValues))]
Age =[self.AgeValues[i].get() for i in range(len(self.AgeValues))]
Code = self.MemberCode.get()
print (Age)
Upvotes: 1