Reputation: 9213
I would like to get the text of the Id column from a Tkinter
treeview when I double click on a child node. Using tree.identify_row(event.y)
I get the values of the other columns returned as a dictionary. I assume the Id is the key of that dictionary, but I can't figure out how to get it.
When I double click on subdir3, I would like to print subdir3
, however, I only get {'two': ' 3B', 'one': '3A'}
from Tkinter import *
import ttk
root = Tk()
def OnDoubleClick(event):
print tree.set(tree.identify_row(event.y))
tree = ttk.Treeview(root)
tree["columns"]=("one","two")
tree.heading("one", text="coulmn A")
tree.heading("two", text="column B")
tree.insert("", 3, "dir3", text="Dir 3",values=("3A"," 3B"))
tree.insert("dir3", 3, 'subdir3', text="sub dir 3",values=("3A"," 3B"))
tree.bind("<Double-1>", OnDoubleClick)
tree.pack()
root.mainloop()
Upvotes: 1
Views: 7745
Reputation: 3574
print tree.identify_row(event.y)
works on my computer.
The third argument of tree.insert
is the iid.
Upvotes: 1