Skip to content

Can we add checkbox and custom right click commands to Treeview? #255

Answered by israel-dryer
sunny9495-dev asked this question in Q&A
Discussion options

You must be logged in to vote

You can use a hack to add a Radiobutton, but it is just a hack.

Then, to add a right-click event, you can use the example below as well. You'll need to create a callback and then bind it to the widget.

import ttkbootstrap as ttk
from ttkbootstrap.constants import HEADINGS, END

CHECKBOX_COLUMN = 2

window = ttk.Window()

tv = ttk.Treeview(columns=[0, 1, 2], show=HEADINGS)
tv.pack(padx=10, pady=10)
tv.heading(0, text="Description")
tv.heading(1, text="Item Number")
tv.heading(CHECKBOX_COLUMN, text="Checkboxes")

# add several items to the treeview
records = []
for x in range(10):
    item = tv.insert('', END, values=('Some random item', x))
    records.append(item)

def initialize_checkbut…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by sunny9495-dev
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants