Python Forum
[Tkinter] How to insert 'Checkbutton' to 'Treeview' and associate each item? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Tkinter] How to insert 'Checkbutton' to 'Treeview' and associate each item? (/thread-31567.html)



How to insert 'Checkbutton' to 'Treeview' and associate each item? - water - Dec-19-2020

I want to insert 'Checkbutton' to 'Treeview' and associate each item to know which items selected,
like this:

[Image: 36356.jpg]

how to do that?
Thanks.
Huh


RE: How to insert 'Checkbutton' to 'Treeview' and associate each item? - Larz60+ - Dec-19-2020

install ttkwidgets: pip install ttkwidgets

Then use example (comes with source): https://github.com/TkinterEP/ttkwidgets

# -*- coding: utf-8 -*-

# Copyright (c) Juliette Monsel 2017
# For license see LICENSE

from ttkwidgets import CheckboxTreeview
import tkinter as tk

root = tk.Tk()

tree = CheckboxTreeview(root)
tree.pack()

tree.insert("", "end", "1", text="1")
tree.insert("1", "end", "11", text="11")
tree.insert("1", "end", "12",  text="12")
tree.insert("11", "end", "111", text="111")
tree.insert("", "end", "2", text="2")

root.mainloop()



RE: How to insert 'Checkbutton' to 'Treeview' and associate each item? - water - Dec-19-2020

Helpful.
Smile