8000 [2.7] bpo-33096: Fix ttk.Treeview.insert. (GH-6228) by serhiy-storchaka · Pull Request #6326 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[2.7] 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..
(cherry picked from commit 3ab44c0)

Co-authored-by: Garvit Khatri <garvitdelhi@gmail.com>
  • Loading branch information
plusminushalf authored and serhiy-storchaka committed Mar 31, 2018
commit f5e6287fa31901297fedbe3b18e47d43455b6868
9 changes: 9 additions & 0 deletions Lib/lib-tk/test/test_ttk/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,15 @@ def test_insert_item(self):
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
Expand Down
2 changes: 1 addition & 1 deletion Lib/lib-tk/ttk.py
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ def insert(self, parent, index, iid=None, **kw):
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:
Expand Down
425F
Loading
0