I'm just starting with a small tkinter tree program in python 3.4.
I'm stuck with returning the first value of the row selected. I have multiple rows with 4 columns and I am calling an a function on left-click on a item:
tree.bind('<Button-1>', selectItem)
The function:
def selectItem(a):
curItem = tree.focus()
print(curItem, a)
This gives me something like this:
I003 <tkinter.Event object at 0x0179D130>
It looks like the selected item gets identified correctly. All I need now is how to get the first value in the row.
tree-creation:
from tkinter import *
from tkinter import ttk
def selectItem():
pass
root = Tk()
tree = ttk.Treeview(root, columns=("size", "modified"))
tree["columns"] = ("date", "time", "loc")
tree.column("date", width=65)
tree.column("time", width=40)
tree.column("loc", width=100)
tree.heading("date", text="Date")
tree.heading("time", text="Time")
tree.heading("loc", text="Loc")
tree.bind('<Button-1>', selectItem)
tree.insert("","end",text = "Name",values = ("Date","Time","Loc"))
tree.grid()
root.mainloop()