Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f91fc65c
Commit
f91fc65c
authored
Jun 14, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #26386: Fixed ttk.TreeView selection operations with item id's
containing spaces.
parent
9925f91b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
1 deletion
+57
-1
Lib/tkinter/test/test_ttk/test_widgets.py
Lib/tkinter/test/test_ttk/test_widgets.py
+51
-0
Lib/tkinter/ttk.py
Lib/tkinter/ttk.py
+3
-1
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/tkinter/test/test_ttk/test_widgets.py
View file @
f91fc65c
...
...
@@ -1486,6 +1486,57 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
value
)
def
test_selection
(
self
):
# item 'none' doesn't exist
self
.
assertRaises
(
tkinter
.
TclError
,
self
.
tv
.
selection_set
,
'none'
)
self
.
assertRaises
(
tkinter
.
TclError
,
self
.
tv
.
selection_add
,
'none'
)
self
.
assertRaises
(
tkinter
.
TclError
,
self
.
tv
.
selection_remove
,
'none'
)
self
.
assertRaises
(
tkinter
.
TclError
,
self
.
tv
.
selection_toggle
,
'none'
)
item1
=
self
.
tv
.
insert
(
''
,
'end'
)
item2
=
self
.
tv
.
insert
(
''
,
'end'
)
c1
=
self
.
tv
.
insert
(
item1
,
'end'
)
c2
=
self
.
tv
.
insert
(
item1
,
'end'
)
c3
=
self
.
tv
.
insert
(
item1
,
'end'
)
self
.
assertEqual
(
self
.
tv
.
selection
(),
())
self
.
tv
.
selection_set
((
c1
,
item2
))
self
.
assertEqual
(
self
.
tv
.
selection
(),
(
c1
,
item2
))
self
.
tv
.
selection_set
(
c2
)
self
.
assertEqual
(
self
.
tv
.
selection
(),
(
c2
,))
self
.
tv
.
selection_add
((
c1
,
item2
))
self
.
assertEqual
(
self
.
tv
.
selection
(),
(
c1
,
c2
,
item2
))
self
.
tv
.
selection_add
(
item1
)
self
.
assertEqual
(
self
.
tv
.
selection
(),
(
item1
,
c1
,
c2
,
item2
))
self
.
tv
.
selection_remove
((
item1
,
c3
))
self
.
assertEqual
(
self
.
tv
.
selection
(),
(
c1
,
c2
,
item2
))
self
.
tv
.
selection_remove
(
c2
)
self
.
assertEqual
(
self
.
tv
.
selection
(),
(
c1
,
item2
))
self
.
tv
.
selection_toggle
((
c1
,
c3
))
self
.
assertEqual
(
self
.
tv
.
selection
(),
(
c3
,
item2
))
self
.
tv
.
selection_toggle
(
item2
)
self
.
assertEqual
(
self
.
tv
.
selection
(),
(
c3
,))
self
.
tv
.
insert
(
''
,
'end'
,
id
=
'with spaces'
)
self
.
tv
.
selection_set
(
'with spaces'
)
self
.
assertEqual
(
self
.
tv
.
selection
(),
(
'with spaces'
,))
self
.
tv
.
insert
(
''
,
'end'
,
id
=
'{brace'
)
self
.
tv
.
selection_set
(
'{brace'
)
self
.
assertEqual
(
self
.
tv
.
selection
(),
(
'{brace'
,))
self
.
tv
.
insert
(
''
,
'end'
,
id
=
'unicode
\
u20ac
'
)
self
.
tv
.
selection_set
(
'unicode
\
u20ac
'
)
self
.
assertEqual
(
self
.
tv
.
selection
(),
(
'unicode
\
u20ac
'
,))
self
.
tv
.
insert
(
''
,
'end'
,
id
=
b'bytes
\
xe2
\
x82
\
xac
'
)
self
.
tv
.
selection_set
(
b'bytes
\
xe2
\
x82
\
xac
'
)
self
.
assertEqual
(
self
.
tv
.
selection
(),
(
'bytes
\
xe2
\
x82
\
xac
'
,))
def
test_set
(
self
):
self
.
tv
[
'columns'
]
=
[
'A'
,
'B'
]
item
=
self
.
tv
.
insert
(
''
,
'end'
,
values
=
[
'a'
,
'b'
])
...
...
Lib/tkinter/ttk.py
View file @
f91fc65c
...
...
@@ -1392,7 +1392,9 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
def
selection
(
self
,
selop
=
None
,
items
=
None
):
"""If selop is not specified, returns selected items."""
return
self
.
tk
.
call
(
self
.
_w
,
"selection"
,
selop
,
items
)
if
isinstance
(
items
,
(
str
,
bytes
)):
items
=
(
items
,)
return
self
.
tk
.
splitlist
(
self
.
tk
.
call
(
self
.
_w
,
"selection"
,
selop
,
items
))
def
selection_set
(
self
,
items
):
...
...
Misc/NEWS
View file @
f91fc65c
...
...
@@ -13,6 +13,9 @@ Core and Builtins
Library
-------
- Issue #26386: Fixed ttk.TreeView selection operations with item id'
s
containing
spaces
.
-
Issue
#
22636
:
Avoid
shell
injection
problems
with
ctypes
.
util
.
find_library
().
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment