For a program that takes information from the network I would like to display it in a table to make selections (calculate average, stdev ect.). I created a list of lists and I am trying to populate it into a treeview table. The populating works, but I get 3 duplicates of every row and the final result as found in the nested list shows 7 duplicates (while my list of lists only shows 1 result per line).
I've been struggling for some time to remove the duplicates and checked the suggestions here.
fullResults = [['a', '1', '2'], ['b', '3', '4'], ['c', '5', '6']]
def displayInfo():
for results in fullResults:
for result in results:
for value in result:
tree.insert('', 'end', values=result)
Can you please point me to some direction as the suggested tree.delete(*tree.get_children())
didn't work for me?
EDIT: after removing the last for loop, I managed to get the issue resolved and data is formatted nicely into the table.
I think that you should not use the loop " for value in result" because you are inserting "values= result" in the last command i.e. "tree.insert". Using for in loop, you are iterating over all the elements in iterable i.e. result. But you are inserting in the treeview- the value that the variable "result" holds. So it means by using the loop you are inserting in the treeview table-n number of times-the value that the variable "result" stores . Here, 'n' is the length of iterable "result".