Nicolas Peille
Nicolas Peille

Reputation: 169

Method to get treeview table into new dataframe

I have some trouble getting back into a new data frame a treeview table.

What I have done so far is showing my data frame into a treeview table and modifying cells. The problem is that I would need to get back this table with the changes into a new dataframe. I am looking for something like this but for a treeview:

for i in range(nb_group):
      label = Label(window1, text='Name group {} : '.format(i+1)).grid(row=i)
      entry = Entry(window1)
      entry.grid(row=i, column=1)
      entries.append(entry)

list_groups = []
   for entry in entries:
       list_groups.append(entry.get())
        window1.destroy()

This is some code about my treeview table

tree.pack(side='top')
b = Button(frame, text='Button1', command=confirmation, padx=20)
b.pack(pady=20, padx=20)
for i in range(counter):
            tree.insert('', i, text=rowLabels[i], values=df_verification_grid_2.iloc[i, :].tolist())
tree.bind('<1>', edit)

My expected result is a dataframe with my treeview table with its new values. Thanks in advance

Upvotes: 0

Views: 956

Answers (1)

Henry Yik
Henry Yik

Reputation: 22493

To get the info of a treeview item, you can use tree.item(iid).

If you need to retrieve the values of all the childs in a treeview widget, you can loop through the results of tree.get_children:

values = []
for child in tree.get_children():
    values.append(tree.item(child)["values"])

Or use a list comprehension:

values = [tree.item(child)["values"] for child in tree.get_children()]

Upvotes: 2

Related Questions