I would like to know , how to make certain nodes in a Treeview object un-selectable, i.e. when clicked on such a node,the node shouldn't highlight.
I am working on
Python 3.3/2.7
Tkinter
I would like to know , how to make certain nodes in a Treeview object un-selectable, i.e. when clicked on such a node,the node shouldn't highlight.
I am working on
Python 3.3/2.7
Tkinter
Create a treeview with the option selectmode="none". This turns off the default selection handling.
Give certain items a tag indicating that you want them to be "selectable".
Create a mouse-click binding on the widget and use the event-handler to set the selection yourself.
def on_click(self, event):
tree = event.widget
item_name = tree.identify_row(event.y)
if item_name:
tags = tree.item(item_name, 'tags')
if tags and (tags[0] == 'selectable'):
tree.selection_set(item_name)