I have noticed an issue with using the tag add
command of a ttk.Treeview
widget when activated with the tk.call()
method. That is, it can't handle white space in the value of the str()
elements of its items
argument.
See this answer on how I had implemented the tag add command. Now if /home/user/Desktop/Secret Source
is passed in to items, the returned error msg is:
self.tk.call(self.tree._w, 'tag', 'add', tag, items)
_tkinter.TclError: Item /home/user/Desktop/Secret not found
The text Source
with one white space is missing from Secret Source
. How do I overcome this error?
CodePudding user response:
The treeview tag add
command requires items
to be a list, but you're passing a string. When tcl is given a string when it expects a list, the string will be split on whitespace to create a list. That is why it thinks the characters before the space is the whole item id.