Unverified Kaydet (Commit) e80a232f authored tarafından Serhiy Storchaka's avatar Serhiy Storchaka Kaydeden (comit) GitHub

[2.7] bpo-33096: Fix ttk.Treeview.insert. (GH-6228) (GH-6326)

Allow ttk.Treeview.insert to insert iid that has a false boolean value.
Note iid=0 and iid=False would be same.
(cherry picked from commit 3ab44c07)
Co-authored-by: 's avatarGarvit Khatri <garvitdelhi@gmail.com>
üst 924035a5
......@@ -1485,6 +1485,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):
# item 'none' doesn't exist
......
......@@ -1332,7 +1332,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:
......
This diff is collapsed.
This diff is collapsed.
Allow ttk.Treeview.insert to insert iid that has a false boolean value.
Note iid=0 and iid=False would be same.
Patch by Garvit Khatri.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment