Tkinter - Add Data From Nested List With Dictionary To Treeview
I am trying to put some data in my treeview and I'm new to the treeview and do'sent understand it fully, if tried to read the documentation, but got even more confused. I created
Solution 1:
Question: add data from nested list with dictionary to treeview
# Set'text'to the firstcolumn heading
tree.heading('#0', text='Name')
# Insert Tree Heading as Item 'dirIso'
# Set'text'to "Isolering"
tree.insert("", 1, "dirIso", text="Isolering")
# Loop first list
for n, dirIso in enumerate(isolering,1):
# Make a list ofvaluesfrom the list of Dictionaries
list_of_column_values =
[list(_dict.values())[0] for _dict in dirIso]
# Insert the list ofvalues
# Firstvalue goes to Treeview 'text'
# All other valuesinto the following Columns
tree.insert('dirIso', n, text=list_of_column_values[0],
values=list_of_column_values[1:])
Tested with Python: 3.5
Post a Comment for "Tkinter - Add Data From Nested List With Dictionary To Treeview"