I’m building a gui using tkk in python and I’m having trouble with the Treeview command selection_set(). I’m trying to use it to set the default selection when my program starts but it seems that it can’t accept a string with spaces in it.
tree.selection_set("Sunset Grill")
Causes:
return self.tk.call(self._w, "selection", selop, items)
_tkinter.TclError: Item Sunset not found
Can anyone give any suggestions?
You might try the following:
I’m guessing this based on the code for
ttk.pyand my limited understanding of Tcl. The call totree.selection_set()callsself.selection("set", items), which in turn callsself.tk.call(self._w, "selection", selop, items)whereselopis'set'and items is the string initially passed toselection_set().I’m not sure if the
self.tk.call()is doing any massaging of the arguments before passing them to Tcl as it’s a call into the_tkinter.c moduleand I don’t know enough about the Python/C interface to grok that code.;)