balaji kommineni
balaji kommineni

Reputation: 127

Tcl Tk treeview with checkbuttons

Is is possible to add check button to ttk::treeview column.

Specifically I am trying to create a checklist for the user to hide or show items on the canvas when the checkbox is selected or deselected. Since there are a lot of canvas items with specific type and sub type I need a list box kind of mechanism.

Upvotes: 1

Views: 2034

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137557

First off, I think you're on the right UI track with a tree of checkboxes (and other things I presume? Descriptive text is good when it comes to helping users with a complex UI.) But now, the bad news.

This is not something that's really supported by the treeview widget. In particular, it has no ability to embed widgets, and nor does it have much in the way of built-in support for handling events on rows. While it would be possible to hack something together — you can always add your own custom bindings, use the widget facilities provided to decode the location information, and simulate buttons through appropriate images — but it would be a lot of work and it definitely would be a hack.

My best suggestion is that you try the tktreectrl widget instead. It's an external package, but it is enormously powerful (so much so that most times people wrap it in code to tame it!) and just looking at some of the demos on that linked page makes me think it can do what you want. Alas, I've no personal experience with using it, so I can't offer detailed instructions.

Upvotes: 2

Related Questions