Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 48743d0

Browse files
committed
Expire cursor-related deprecations
1 parent 924e210 commit 48743d0

File tree

8 files changed

+34
-83
lines changed

8 files changed

+34
-83
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Interactive cursor details
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Setting a mouse cursor on a window has been moved from the toolbar to the
5+
canvas. Consequently, several implementation details on toolbars and within
6+
backends have been removed.
7+
8+
``NavigationToolbar2.set_cursor`` and ``backend_tools.SetCursorBase.set_cursor``
9+
................................................................................
10+
11+
Instead, use the `.FigureCanvasBase.set_cursor` method on the canvas (available
12+
as the ``canvas`` attribute on the toolbar or the Figure.)
13+
14+
``backend_tools.SetCursorBase`` and subclasses
15+
..............................................
16+
17+
``backend_tools.SetCursorBase`` was subclassed to provide backend-specific
18+
implementations of ``set_cursor``. As that is now removed, the subclassing
19+
is no longer necessary. Consequently, the following subclasses are also
20+
removed:
21+
22+
- ``matplotlib.backends.backend_gtk3.SetCursorGTK3``
23+
- ``matplotlib.backends.backend_qt5.SetCursorQt``
24+
- ``matplotlib.backends._backend_tk.SetCursorTk``
25+
- ``matplotlib.backends.backend_wx.SetCursorWx``
26+
27+
Instead, use the `.backend_tools.ToolSetCursor` class.
28+
29+
``cursord`` in GTK and wx backends
30+
.......................................
31+
32+
The ``backend_gtk3.cursord`` and ``backend_wx.cursord`` dictionaries are
33+
removed. This makes the GTK module importable on headless environments.

lib/matplotlib/backend_bases.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3296,18 +3296,6 @@ def save_figure(self, *args):
32963296
"""Save the current figure."""
32973297
raise NotImplementedError
32983298

3299-
@_api.deprecated("3.5", alternative="`.FigureCanvasBase.set_cursor`")
3300-
def set_cursor(self, cursor):
3301-
"""
3302-
Set the current cursor to one of the :class:`Cursors` enums values.
3303-
3304-
If required by the backend, this method should trigger an update in
3305-
the backend event loop after the cursor is set, as this method may be
3306-
called e.g. before a long-running task during which the GUI is not
3307-
updated.
3308-
"""
3309-
self.canvas.set_cursor(cursor)
3310-
33113299
def update(self):
33123300
"""Reset the Axes stack."""
33133301
self._nav_stack.clear()

lib/matplotlib/backend_tools.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -310,18 +310,6 @@ def _set_cursor_cbk(self, event):
310310
self.canvas.set_cursor(self._default_cursor)
311311
self._last_cursor = self._default_cursor
312312

313-
@_api.deprecated("3.5", alternative="`.FigureCanvasBase.set_cursor`")
314-
def set_cursor(self, cursor):
315-
"""
316-
Set the cursor.
317-
"""
318-
self.canvas.set_cursor(cursor)
319-
320-
321-
# This exists solely for deprecation warnings; remove with
322-
# SetCursorBase.set_cursor.
323-
ToolSetCursor = SetCursorBase
324-
325313

326314
class ToolCursorPosition(ToolBase):
327315
"""

lib/matplotlib/backends/_backend_tk.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -910,13 +910,6 @@ def remove_rubberband(self):
910910
property(lambda self: self.figure.canvas._rubberband_rect))
911911

912912

913-
@_api.deprecated("3.5", alternative="ToolSetCursor")
914-
class SetCursorTk(backend_tools.SetCursorBase):
915-
def set_cursor(self, cursor):
916-
NavigationToolbar2Tk.set_cursor(
917-
self._make_classic_style_pseudo_toolbar(), cursor)
918-
919-
920913
class ToolbarTk(ToolContainerBase, tk.Frame):
921914
def __init__(self, toolmanager, window=None):
922915
ToolContainerBase.__init__(self, toolmanager)

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from matplotlib.backend_bases import (
1010
FigureCanvasBase, ToolContainerBase,
1111
CloseEvent, KeyEvent, LocationEvent, MouseEvent, ResizeEvent)
12-
from matplotlib.backend_tools import Cursors
1312

1413
try:
1514
import gi
@@ -39,22 +38,6 @@
3938

4039
@_api.caching_module_getattr # module-level deprecations
4140
class __getattr__:
42-
@_api.deprecated("3.5", obj_type="")
43-
@property
44-
def cursord(self):
45-
try:
46-
new_cursor = functools.partial(
47-
Gdk.Cursor.new_from_name, Gdk.Display.get_default())
48-
return {
49-
Cursors.MOVE: new_cursor("move"),
50-
Cursors.HAND: new_cursor("pointer"),
51-
Cursors.POINTER: new_cursor("default"),
52-
Cursors.SELECT_REGION: new_cursor("crosshair"),
53-
Cursors.WAIT: new_cursor("wait"),
54-
}
55-
except TypeError:
56-
return {}
57-
5841
icon_filename = _api.deprecated("3.6", obj_type="")(property(
5942
lambda self:
6043
"matplotlib.png" if sys.platform == "win32" else "matplotlib.svg"))
@@ -493,13 +476,6 @@ def trigger(self, *args, **kwargs):
493476
self._make_classic_style_pseudo_toolbar())
494477

495478

496-
@_api.deprecated("3.5", alternative="ToolSetCursor")
497-
class SetCursorGTK3(backend_tools.SetCursorBase):
498-
def set_cursor(self, cursor):
499-
NavigationToolbar2GTK3.set_cursor(
500-
self._make_classic_style_pseudo_toolbar(), cursor)
501-
502-
503479
@backend_tools._register_tool_class(FigureCanvasGTK3)
504480
class HelpGTK3(backend_tools.ToolHelpBase):
505481
def _normalize_shortcut(self, key):

lib/matplotlib/backends/backend_qt.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -976,13 +976,6 @@ def trigger(self, *args):
976976
self._make_classic_style_pseudo_toolbar())
977977

978978

979-
@_api.deprecated("3.5", alternative="ToolSetCursor")
980-
class SetCursorQt(backend_tools.SetCursorBase):
981-
def set_cursor(self, cursor):
982-
NavigationToolbar2QT.set_cursor(
983-
self._make_classic_style_pseudo_toolbar(), cursor)
984-
985-
986979
@backend_tools._register_tool_class(FigureCanvasQT)
987980
class RubberbandQt(backend_tools.RubberbandBase):
988981
def draw_rubberband(self, x0, y0, x1, y1):

lib/matplotlib/backends/backend_qt5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Public API
99
cursord, _create_qApp, _BackendQT, TimerQT, MainWindow, FigureCanvasQT,
1010
FigureManagerQT, ToolbarQt, NavigationToolbar2QT, SubplotToolQt,
11-
SaveFigureQt, ConfigureSubplotsQt, SetCursorQt, RubberbandQt,
11+
SaveFigureQt, ConfigureSubplotsQt, RubberbandQt,
1212
HelpQt, ToolCopyToClipboardQT,
1313
# internal re-exports
1414
FigureCanvasBase, FigureManagerBase, MouseButton, NavigationToolbar2,

lib/matplotlib/backends/backend_wx.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,6 @@
3939
PIXELS_PER_INCH = 75
4040

4141

42-
@_api.caching_module_getattr # module-level deprecations
43-
class __getattr__:
44-
cursord = _api.deprecated("3.5", obj_type="")(property(lambda self: {
45-
cursors.MOVE: wx.CURSOR_HAND,
46-
cursors.HAND: wx.CURSOR_HAND,
47-
cursors.POINTER: wx.CURSOR_ARROW,
48-
cursors.SELECT_REGION: wx.CURSOR_CROSS,
49-
cursors.WAIT: wx.CURSOR_WAIT,
50-
cursors.RESIZE_HORIZONTAL: wx.CURSOR_SIZEWE,
51-
cursors.RESIZE_VERTICAL: wx.CURSOR_SIZENS,
52-
}))
53-
54-
5542
@_api.deprecated("3.6")
5643
def error_msg_wx(msg, parent=None):
5744
"""Signal an error condition with a popup error dialog."""
@@ -1292,13 +1279,6 @@ def trigger(self, *args):
12921279
self._make_classic_style_pseudo_toolbar())
12931280

12941281

1295-
@_api.deprecated("3.5", alternative="ToolSetCursor")
1296-
class SetCursorWx(backend_tools.SetCursorBase):
1297-
def set_cursor(self, cursor):
1298-
NavigationToolbar2Wx.set_cursor(
1299-
self._make_classic_style_pseudo_toolbar(), cursor)
1300-
1301-
13021282
@backend_tools._register_tool_class(_FigureCanvasWxBase)
13031283
class RubberbandWx(backend_tools.RubberbandBase):
13041284
def draw_rubberband(self, x0, y0, x1, y1):

0 commit comments

Comments
 (0)