mirror of
https://github.com/python/cpython.git
synced 2025-09-30 20:31:52 +00:00
[3.6] bpo-27319, bpo-31508: Document deprecation in Treeview.selection(). (GH-3667) (#3719)
Defer removing old behavior to 3.8.
Document new feature of selection_set() and friends.
(cherry picked from commit 2fad102354
)
This commit is contained in:
parent
018e6b9f69
commit
e31eca45e5
3 changed files with 23 additions and 7 deletions
|
@ -1099,26 +1099,42 @@ ttk.Treeview
|
||||||
If *selop* is not specified, returns selected items. Otherwise, it will
|
If *selop* is not specified, returns selected items. Otherwise, it will
|
||||||
act according to the following selection methods.
|
act according to the following selection methods.
|
||||||
|
|
||||||
|
.. deprecated-removed:: 3.6 3.8
|
||||||
|
Using ``selection()`` for changing the selection state is deprecated.
|
||||||
|
Use the following selection methods instead.
|
||||||
|
|
||||||
.. method:: selection_set(items)
|
|
||||||
|
.. method:: selection_set(*items)
|
||||||
|
|
||||||
*items* becomes the new selection.
|
*items* becomes the new selection.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.6
|
||||||
|
*items* can be passed as separate arguments, not just as a single tuple.
|
||||||
|
|
||||||
.. method:: selection_add(items)
|
|
||||||
|
.. method:: selection_add(*items)
|
||||||
|
|
||||||
Add *items* to the selection.
|
Add *items* to the selection.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.6
|
||||||
|
*items* can be passed as separate arguments, not just as a single tuple.
|
||||||
|
|
||||||
.. method:: selection_remove(items)
|
|
||||||
|
.. method:: selection_remove(*items)
|
||||||
|
|
||||||
Remove *items* from the selection.
|
Remove *items* from the selection.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.6
|
||||||
|
*items* can be passed as separate arguments, not just as a single tuple.
|
||||||
|
|
||||||
.. method:: selection_toggle(items)
|
|
||||||
|
.. method:: selection_toggle(*items)
|
||||||
|
|
||||||
Toggle the selection state of each item in *items*.
|
Toggle the selection state of each item in *items*.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.6
|
||||||
|
*items* can be passed as separate arguments, not just as a single tuple.
|
||||||
|
|
||||||
|
|
||||||
.. method:: set(item, column=None, value=None)
|
.. method:: set(item, column=None, value=None)
|
||||||
|
|
||||||
|
|
|
@ -1556,7 +1556,7 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
|
||||||
self.tv.selection_toggle((c1, c3))
|
self.tv.selection_toggle((c1, c3))
|
||||||
self.assertEqual(self.tv.selection(), (c3, item2))
|
self.assertEqual(self.tv.selection(), (c3, item2))
|
||||||
|
|
||||||
if sys.version_info >= (3, 7):
|
if sys.version_info >= (3, 8):
|
||||||
import warnings
|
import warnings
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'Deprecated API of Treeview.selection() should be removed')
|
'Deprecated API of Treeview.selection() should be removed')
|
||||||
|
|
|
@ -1404,13 +1404,13 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
|
||||||
import warnings
|
import warnings
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"The selop=None argument of selection() is deprecated "
|
"The selop=None argument of selection() is deprecated "
|
||||||
"and will be removed in Python 3.7",
|
"and will be removed in Python 3.8",
|
||||||
DeprecationWarning, 3)
|
DeprecationWarning, 3)
|
||||||
elif selop in ('set', 'add', 'remove', 'toggle'):
|
elif selop in ('set', 'add', 'remove', 'toggle'):
|
||||||
import warnings
|
import warnings
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"The selop argument of selection() is deprecated "
|
"The selop argument of selection() is deprecated "
|
||||||
"and will be removed in Python 3.7, "
|
"and will be removed in Python 3.8, "
|
||||||
"use selection_%s() instead" % (selop,),
|
"use selection_%s() instead" % (selop,),
|
||||||
DeprecationWarning, 3)
|
DeprecationWarning, 3)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue