Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python treeview update tag

I have inserted items into a Python treeview with tag option.

tree.insert("", 'end', 'item1', text='item1', tags=('new',))

Is it possible to change the tag "new" to something else later?

like image 866
Hugh M Avatar asked Dec 22 '25 02:12

Hugh M


1 Answers

You can modify any of the options of an item. So if you want to change 'item1' tags to for example 'old':

tree.item('item1', tags=('old'))

From Python docs about ttk.Treeview:

item(item, option=None, **kw) Query or modify the options for the specified item.

If no options are given, a dict with options/values for the item is returned. If option is specified then the value for that option is returned. Otherwise, sets the options to the corresponding values as given by kw.

like image 76
oystein-hr Avatar answered Dec 24 '25 00:12

oystein-hr