Skip to content

Commit 2fad102

Browse files
bpo-27319, bpo-31508: Document deprecation in Treeview.selection(). (#3667)
Defer removing old behavior to 3.8. Document new feature of selection_set() and friends.
1 parent c247caf commit 2fad102

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

‎Doc/library/tkinter.ttk.rst‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,26 +1099,42 @@ ttk.Treeview
10991099
If *selop* is not specified, returns selected items. Otherwise, it will
11001100
act according to the following selection methods.
11011101

1102+
.. deprecated-removed:: 3.6 3.8
1103+
Using ``selection()`` for changing the selection state is deprecated.
1104+
Use the following selection methods instead.
11021105

1103-
.. method:: selection_set(items)
1106+
1107+
.. method:: selection_set(*items)
11041108

11051109
*items* becomes the new selection.
11061110

1111+
.. versionchanged:: 3.6
1112+
*items* can be passed as separate arguments, not just as a single tuple.
1113+
11071114

1108-
.. method:: selection_add(items)
1115+
.. method:: selection_add(*items)
11091116

11101117
Add *items* to the selection.
11111118

1119+
.. versionchanged:: 3.6
1120+
*items* can be passed as separate arguments, not just as a single tuple.
1121+
11121122

1113-
.. method:: selection_remove(items)
1123+
.. method:: selection_remove(*items)
11141124

11151125
Remove *items* from the selection.
11161126

1127+
.. versionchanged:: 3.6
1128+
*items* can be passed as separate arguments, not just as a single tuple.
11171129

1118-
.. method:: selection_toggle(items)
1130+
1131+
.. method:: selection_toggle(*items)
11191132

11201133
Toggle the selection state of each item in *items*.
11211134

1135+
.. versionchanged:: 3.6
1136+
*items* can be passed as separate arguments, not just as a single tuple.
1137+
11221138

11231139
.. method:: set(item, column=None, value=None)
11241140

‎Lib/tkinter/test/test_ttk/test_widgets.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ def test_selection(self):
15561556
self.tv.selection_toggle((c1, c3))
15571557
self.assertEqual(self.tv.selection(), (c3, item2))
15581558

1559-
if sys.version_info >= (3, 7):
1559+
if sys.version_info >= (3, 8):
15601560
import warnings
15611561
warnings.warn(
15621562
'Deprecated API of Treeview.selection() should be removed')

‎Lib/tkinter/ttk.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,13 +1404,13 @@ def selection(self, selop=_sentinel, items=None):
14041404
import warnings
14051405
warnings.warn(
14061406
"The selop=None argument of selection() is deprecated "
1407-
"and will be removed in Python 3.7",
1407+
"and will be removed in Python 3.8",
14081408
DeprecationWarning, 3)
14091409
elif selop in ('set', 'add', 'remove', 'toggle'):
14101410
import warnings
14111411
warnings.warn(
14121412
"The selop argument of selection() is deprecated "
1413-
"and will be removed in Python 3.7, "
1413+
"and will be removed in Python 3.8, "
14141414
"use selection_%s() instead" % (selop,),
14151415
DeprecationWarning, 3)
14161416
else:

0 commit comments

Comments
 (0)