Reputation: 31
Using tkinter in the gui I'm building an array made of entry boxes. In some columns of the array I'm entering values which i read them and build a list for every column. There are also columns without values which are readonly in which I want to export results from lists. I can't find how to make the program to show the results.
Keep in mind that i have two defs one for building the widgets and one for the calculations.
In order to build one empty-results column I make this:
self.akt_b =[]
for i in range(12):
akt_b =StringVar()
self.akt_b =Entry(self, textvariable =akt_b, width =10,
state='readonly', readonlybackground ="white")
self.akt_b.grid(row =7+i, column =3)
which makes visually what I want. Then I calculate a list_b of 12 float numbers which I want to show in self.akt_b I'm trying:
for i in range(12):
self.akt_b[i+1].delete(0, END)
self.akt_b[(i+1)].set("round(list_b[(i+1)], 2)")
which doesn't work I've tried also .insert not again, I've tried akt_b nothing again
what can I do?
Upvotes: 0
Views: 1918
Reputation: 31
after Kevin's answer I found out the solution, I was missing the .append argument.
Just in case anyone is interested here is the solution:
self.akt_b, self.entries =[], []
for i in range(12):
akt_b =StringVar()
entries =Entry(self, textvariable =akt_b, width =10,
state='readonly', readonlybackground ="white")
entries.grid(row =7+i, column =3)
self.akt_b.append(akt_b)
so now
for i in range(12):
self.akt_b[i].set(round(list_b[i], 2))
works perfect.
Sometimes brain just seems to stop...
Upvotes: 2