Move item from one treeview to another treeview same line of row

Screenshot by Lightshot I want to move data from tv to tv3 same line

# Frame for TreeView
frame2 = Frame(root)
frame2.pack(side=tk.TOP,pady=25)

tv2 = ttk.Treeview(frame2, columns=(1), show="headings", height="15")
tv2.pack()
tv2.heading(1, text="All word")

frame1 = Frame(root)
frame1.pack(side=tk.TOP,pady=25)

tv = ttk.Treeview(frame1, columns=(1), show="headings", height="15")
tv.pack()
tv.heading(1, text="one word")

frame3 = Frame(root)
frame3.pack(side=tk.TOP,pady=25)

tv3 = ttk.Treeview(frame3, columns=(1), show="headings", height="15")
tv3.pack()
tv3.heading(1, text="Valid Word")

frame1.grid(row=0,column=1)
frame2.grid(row=0,column=0,padx=5)
frame3.grid(row=0,column=3,padx=5)



tv.bind("<Double-1>", addToValid)

def addToValid(self):
    item = tv.item(tv.selection())['values'][0]
    print("you clicked on move", item)


    for ic in range(1):
        print('ic',ic)
        tv3.move(item,tv.parent(ic), tv3.index(ic))

Hi Bikram,

What’s a treeview? What are tv and tv3?

Are you suggesting this as a new idea for Python or asking for help?

you can see the screenshot above the code

No, I can’t see the screenshot. The URL you provide is blocked here. But
if I could see it, would it answer my questions?

Are you asking for help, or making a suggestion for a new feature for
the Python language?

The “Ideas” topic is for new features. If you are asking for help, you
should post under the “Users” topic, and you should explain what you are
trying to do.

Help us to help you!

You should follow the same standards as StackOverflow:

If you are posting an image of a GUI, that is okay, but ideally we
should be able to understand your question without seeing the image. (I
understand that is not always possible.)

this question is related to python’s built in GUI module, tkinter. treeview is to display data by rows.

I see you’ve used:

tv.item(tv.selection())['values'][0]

This would get only the first value in that specific row into a list (e.g., if your row was | value 1 | value 2 | value 3| , tree_a.item(child)["values"][0] would equal to value 1. You might want to get all the values from specific row you want to move, and put them in the other treeview instead of just one item. Then delete the original row still in the original treeview.

Modify your function:

def addToValid(self):
    item = tv.item(tv.selection())['values']
    print("you clicked on move", item)
    tv3.insert("",0,text="",values=item) # add the data into the new treeview
    tv.delete(tv.item(tv.selection())) # this is to delete the data from the original row

There you have it!