4

is there any way I could modify the the tkinter treeview item tag? I know how to create item with tag with insert command, but when I:

tree.set(tree.selection()[0],0,'some text in red', tags='red')

I get TypeError: set() got an unexpected keyword argument 'tags'

The ultimate goal is to change row or column colors... Thanks!

HK boy
  • 1,398
  • 11
  • 17
  • 25
sssseossss
  • 131
  • 2
  • 2
  • 6

1 Answers1

10

The documentation on Treeview (here for instance) says that there is a method called item that can be used to set or retrieve the options of a tree item.

  • tree.item(iid, "tags") returns the list of tags of the item identified by iid

  • tree.item(iid, tags="red") changes the tags of iid to ("red",). You can also pass a tuple of tags like tags=("bold", "red").

j_4321
  • 15,431
  • 3
  • 34
  • 61