0

I need to create a button in each tree view line like this https://i.stack.imgur.com/BQFI8.png with a drop down list of actions to perform like this https://i.stack.imgur.com/ZSL9r.png. Is this possible, and if so how?

Thanks a lot!

2 Answers2

0

Try to recycle this code:

from tkinter import *
from tkinter import ttk

root = Tk()

tree = ttk.Treeview(root)

tree["columns"]=("one","two")
tree.column("one", width=100 )
tree.column("two", width=100)
tree.heading("one", text="coulmn A")
tree.heading("two", text="column B")

tree.insert("" , 0,    text="Line 1", values=("1A","1b"))

id2 = tree.insert("", 1, "dir2", text="Dir 2")
tree.insert(id2, "end", "dir 2", text="sub dir 2", values=("2A","2B"))
tree.insert(id2, "end", "dir 3", text="sub dir 2", values=("2A","2B"))

##alternatively:
tree.insert("", 3, "dir3", text="Dir 3")
tree.insert("dir3", 3, text=" sub dir 3",values=("3A"," 3B"))

tree.pack()
root.mainloop()

Good luck.

Izalion
  • 708
  • 4
  • 11
  • it doesn't work :/ I already added a button in each line in the external.id = pl.process_tree, now i need to have a drop-down list of actions (Copy, Share, Print, Delete..) when pressed that button – Riicardo Stifler Aug 07 '19 at 15:20
0

Embedded widgets being used within a ttk.Treeview cell doesn't seem to be a possibility (according to this) - but you can program a cell to act like a widget by binding mouse-clicks to a function that calls the .identify_region, .identify_row, and .identify_column methods. Similar thread: 46624143.

Peetza
  • 64
  • 6