diff options
author | Garvit Khatri <garvitdelhi@gmail.com> | 2018-03-26 07:02:05 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2018-03-26 07:02:05 (GMT) |
commit | 3ab44c0783eebdff687014f7d14d5dec59b6bd39 (patch) | |
tree | 77df1a4b12402a9498ad17e81cd39cdeb58e1552 /Lib/tkinter | |
parent | 2b75fc2bc97702224de0fae8ab026ec0cd0706ab (diff) | |
download | cpython-3ab44c0783eebdff687014f7d14d5dec59b6bd39.zip cpython-3ab44c0783eebdff687014f7d14d5dec59b6bd39.tar.gz cpython-3ab44c0783eebdff687014f7d14d5dec59b6bd39.tar.bz2 |
bpo-33096: Fix ttk.Treeview.insert. (GH-6228)
Allow ttk.Treeview.insert to insert iid that has a false boolean value.
Note iid=0 and iid=False would be same.
Diffstat (limited to 'Lib/tkinter')
-rw-r--r-- | Lib/tkinter/test/test_ttk/test_widgets.py | 9 | ||||
-rw-r--r-- | Lib/tkinter/ttk.py | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/Lib/tkinter/test/test_ttk/test_widgets.py b/Lib/tkinter/test/test_ttk/test_widgets.py index bbc508d..5b0e29c 100644 --- a/Lib/tkinter/test/test_ttk/test_widgets.py +++ b/Lib/tkinter/test/test_ttk/test_widgets.py @@ -1662,6 +1662,15 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase): self.tv.insert('', 'end', text=value), text=None), value) + # test for values which are not None + itemid = self.tv.insert('', 'end', 0) + self.assertEqual(itemid, '0') + itemid = self.tv.insert('', 'end', 0.0) + self.assertEqual(itemid, '0.0') + # this is because False resolves to 0 and element with 0 iid is already present + self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end', False) + self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end', '') + def test_selection(self): self.assertRaises(TypeError, self.tv.selection, 'spam') diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py index 490b502..573544d 100644 --- a/Lib/tkinter/ttk.py +++ b/Lib/tkinter/ttk.py @@ -1361,7 +1361,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): already exist in the tree. Otherwise, a new unique identifier is generated.""" opts = _format_optdict(kw) - if iid: + if iid is not None: res = self.tk.call(self._w, "insert", parent, index, "-id", iid, *opts) else: |