oystein-hr gaves you solution and you can use it as normal function.
Example base on Byan Oakley example code:
https://stackoverflow.com/a/3794505/1832058
and Bryan Oakley suggestion to use <<TreeviewSelect>>
: https://stackoverflow.com/a/12064135/1832058
import tkinter as tk
from tkinter import ttk
def OnDoubleClick(event):
item = tree.selection()
print('item:', item)
print('event:', event)
item = tree.selection()[0]
print("you clicked on", tree.item(item,"text"))
root = tk.Tk()
tree = ttk.Treeview()
tree.pack()
for i in range(10):
tree.insert("", "end", text="Item %s" % i)
#tree.bind("<Double-1>", OnDoubleClick) # double click
#tree.bind("<Button-1>", OnDoubleClick) # single click
tree.bind("<<TreeviewSelect>>", OnDoubleClick) # single click, without "index out of range" error
root.mainloop()
No row "act as a button" because you can click it to run function.