This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: ttk.Treeview.insert() does not allow to insert item with "False" iid
Type: behavior Stage: resolved
Components: Tkinter Versions: Python 3.8, Python 3.7, Python 3.6, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: garvitdelhi, gpolo, igor.yakovchenko, miss-islington, serhiy.storchaka, terry.reedy
Priority: normal Keywords: easy, patch

Created on 2018-03-18 09:09 by igor.yakovchenko, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 6228 merged garvitdelhi, 2018-03-25 07:06
PR 6246 merged miss-islington, 2018-03-26 07:03
PR 6247 merged miss-islington, 2018-03-26 07:05
PR 6326 merged serhiy.storchaka, 2018-03-31 21:05
PR 6724 merged serhiy.storchaka, 2018-05-08 05:06
Messages (10)
msg314032 - (view) Author: Igor Yakovchenko (igor.yakovchenko) Date: 2018-03-18 09:09
ttk.Treeview.insert(... iid=None, ...) method has a check:
        if iid:
            res =, "insert", parent, index,
                "-id", iid, *opts)
            res =, "insert", parent, index, *opts)

Documentation says that "If iid is specified, it is used as the item identifier", but as you can see from code, iid is used only if it's "True". It means that you cannot use iids like 0, 0.0 etc.
msg314338 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-03-23 22:53
This was initially reported in pydev thread "ttk.Treeview.insert() does not allow to insert item with iid=0" on 2018/3/16.  Igor, you should have mentioned on the thread that you had opened a tracker issue in response.  It was only happenstance that I did not open a duplicate.

I suggested there that 'if iid:' be replaced by 'if iid is not None:' but wondered if passing '"-id" ""' in the would be a problem.  If so, that would be a reason for the expanded check and suggest 'if iid in (None, ''):" as the replacement.

MRAB responded that '' is the id of the root of the tree.  But that does not tell me if passing a duplicate iid or that particular duplicate is a problem or not.
msg314356 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-03-24 05:19
I have tested -- omitting the option and passing an empty string are treated different in Tk. Passing a duplicate iid is error. Thus the fix should be just `iid is not None`. But needed tests.
msg314381 - (view) Author: Garvit Khatri (garvitdelhi) * Date: 2018-03-24 18:45
I made the changes on my machine and I\in my testing, it breaks on an empty string with an error saying
"Item already exists". If this is expected I would like to submit a patch with tests for the same.
msg314383 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-03-24 19:25
Yes, this is expected.
msg314439 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-03-26 07:02
New changeset 3ab44c0783eebdff687014f7d14d5dec59b6bd39 by Serhiy Storchaka (Garvit Khatri) in branch 'master':
bpo-33096: Fix ttk.Treeview.insert. (GH-6228)
msg314440 - (view) Author: miss-islington (miss-islington) Date: 2018-03-26 08:19
New changeset a7b1b847f665aafc22557917cea32ec34c9b4418 by Miss Islington (bot) in branch '3.7':
bpo-33096: Fix ttk.Treeview.insert. (GH-6228)
msg314441 - (view) Author: miss-islington (miss-islington) Date: 2018-03-26 08:20
New changeset 45116d393f713bbe918f16b33a0bba28b15bc96b by Miss Islington (bot) in branch '3.6':
bpo-33096: Fix ttk.Treeview.insert. (GH-6228)
msg314751 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-03-31 23:43
New changeset e80a232f2cfdab584133d9779c83885c5f9f1ba6 by Serhiy Storchaka in branch '2.7':
[2.7] bpo-33096: Fix ttk.Treeview.insert. (GH-6228) (GH-6326)
msg316280 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-08 07:09
New changeset 903f189b6e528cbe9500014c6f990c6511b38918 by Serhiy Storchaka in branch '2.7':
bpo-33096: Removed unintentionally backported from Python 3 Tkinter files. (GH-6724)
Date User Action Args
2022-04-11 14:58:58adminsetgithub: 77277
2018-05-08 07:09:11serhiy.storchakasetmessages: + msg316280
2018-05-08 05:06:35serhiy.storchakasetpull_requests: + pull_request6417
2018-04-01 07:43:55serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-03-31 23:43:00serhiy.storchakasetmessages: + msg314751
2018-03-31 21:05:39serhiy.storchakasetpull_requests: + pull_request6040
2018-03-26 08:20:12miss-islingtonsetmessages: + msg314441
2018-03-26 08:19:54miss-islingtonsetnosy: + miss-islington
messages: + msg314440
2018-03-26 07:05:17miss-islingtonsetpull_requests: + pull_request5980
2018-03-26 07:03:30miss-islingtonsetpull_requests: + pull_request5979
2018-03-26 07:02:08serhiy.storchakasetmessages: + msg314439
2018-03-25 07:06:48garvitdelhisetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request5967
2018-03-24 19:25:37serhiy.storchakasetmessages: + msg314383
2018-03-24 18:45:22garvitdelhisetnosy: + garvitdelhi
messages: + msg314381
2018-03-24 05:19:40serhiy.storchakasetkeywords: + easy

messages: + msg314356
stage: needs patch
2018-03-23 22:53:09terry.reedysetnosy: + terry.reedy
messages: + msg314338
2018-03-18 09:19:26serhiy.storchakasetassignee: serhiy.storchaka
versions: + Python 2.7, Python 3.7, Python 3.8
2018-03-18 09:09:10igor.yakovchenkocreate