[Python-Dev] ttk.Treeview.insert() does not allow to insert item with iid=0
python at mrabarnett.plus.com
Fri Mar 16 20:39:06 EDT 2018
On 2018-03-16 20:22, Terry Reedy wrote:
> On 3/16/2018 6:54 AM, Игорь Яковченко wrote:
>> There is no item with such iid. This item has autogenerated iid just
>> like it's not specified.
>> I investigated problem and found that in ttk.py, Treeview.insert(...
>> iid=None, ...) in method's body has a check:
>> if iid:
>> res = self.tk.call(self._w, "insert", parent, index,
>> "-id", iid, *opts)
>> res = self.tk.call(self._w, "insert", parent, index, *opts)
>> It means that if iid is "True" then use it else autogenerate it.
>> Maybe there should be "if iid is not None", not "if iid"? Or there are
>> some reasons to do check this way?
> It might be that accepting '' as an iid would be a problem.
> Our current tkinter expert, Serhiy Storchaka, should know. If so, "if
> iid in (None, '')" would be needed.
The root of the tree has the iid ''.
More information about the Python-Dev