I have a function creating entries via grid() like this: (replace while-loop with function, this should just show you what it looks like later)
from Tkinter import *
root = Tk()
index=0
while index < 10:
col0 = Text(root,width=20, height=1, bg='white')
col0.grid(row=index,column=0)
col0.insert('0.0',"name")
col1 = Text(root,width=20, height=1, bg='white')
col1.grid(row=index,column=1)
col1.insert('0.0',"attribute #1")
col2 = Text(root,width=20, height=1, bg='white')
col2.grid(row=index,column=2)
col2.insert('0.0',"attribute #2")
col3 = Text(root,width=20, height=1, bg='white')
col3.grid(row=index,column=3)
col3.insert('0.0',"counter")
index+=1
root.mainloop()
so on special events the function is called and creates a new entry (a new row). but if there is already an entry for this event, i just want to increase the counter.
the eventnames and their entryrows (index) are saved in a dictionary, so i do have the row and column, but how can i actually access col3 now?
i planned to get the counter via col3.get(), but it is called col3 in every row, so how could i specify it?
is it alternatively possible to put col0,col1,col2 etc into a kind of structure (like a dictionary), so access them via col0[name].insert()… (name is unique)? i tried that but that did not work out (which does not mean its impossible i hope, i am just quite new to python)
does anyone have any suggestions or solutions to my problem?
You need to save references to all the Text widgets that you create:
This would allow you to access each widget by it’s row/column:
You could easily append a new row to this structure like so:
With this structure, it’s not the names that are unique, but the positions of each cell.