[Python-Dev] ttk.Treeview.insert() does not allow to insert item with iid=0

Игорь Яковченко truestarecat at gmail.com
Fri Mar 16 06:54:51 EDT 2018


I found a possible bug with ttk.Treeview widget.
I'm working on program that uses tkinter UI. I use ttk.Treeview to display
some objects and I want to use integer iid of items.
For example, I insert a row with treeview.insert(... iid=0, ...). But I
encountered a problem when I try to get this item from treeview by iid when
iid =0.
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?

Igor Yakovchenko

вирусов. www.avast.ru
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180316/681220e2/attachment.html>

More information about the Python-Dev mailing list