Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b7db7c9

Browse filesBrowse files
authored
Merge pull request #24129 from oscargus/cursorremovals
Expire cursor-related deprecations
2 parents f95cdd3 + adc305c commit b7db7c9
Copy full SHA for b7db7c9

File tree

Expand file treeCollapse file tree

9 files changed

+38
-97
lines changed
Filter options
Expand file treeCollapse file tree

9 files changed

+38
-97
lines changed
+33Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
-12Lines 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_managers.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_managers.py
-10Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,6 @@ def add_tool(self, name, tool, *args, **kwargs):
257257
'exists, not added')
258258
return self._tools[name]
259259

260-
if name == 'cursor' and tool_cls != backend_tools.SetCursorBase:
261-
_api.warn_deprecated("3.5",
262-
message="Overriding ToolSetCursor with "
263-
f"{tool_cls.__qualname__} was only "
264-
"necessary to provide the .set_cursor() "
265-
"method, which is deprecated since "
266-
"%(since)s and will be removed "
267-
"%(removal)s. Please report this to the "
268-
f"{tool_cls.__module__} author.")
269-
270260
tool_obj = tool_cls(self, name, *args, **kwargs)
271261
self._tools[name] = tool_obj
272262

‎lib/matplotlib/backend_tools.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_tools.py
+4-16Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,12 @@ def set_figure(self, figure):
252252
self._toggled = True
253253

254254

255-
class SetCursorBase(ToolBase):
255+
class ToolSetCursor(ToolBase):
256256
"""
257257
Change to the current cursor while inaxes.
258258
259-
This tool, keeps track of all `ToolToggleBase` derived tools, and calls
260-
`set_cursor` when a tool gets triggered.
259+
This tool, keeps track of all `ToolToggleBase` derived tools, and updates
260+
the cursor when a tool gets triggered.
261261
"""
262262
def __init__(self, *args, **kwargs):
263263
super().__init__(*args, **kwargs)
@@ -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
"""
@@ -979,7 +967,7 @@ def trigger(self, *args, **kwargs):
979967
'yscale': ToolYScale,
980968
'position': ToolCursorPosition,
981969
_views_positions: ToolViewsPositions,
982-
'cursor': SetCursorBase,
970+
'cursor': ToolSetCursor,
983971
'rubberband': RubberbandBase,
984972
'help': ToolHelpBase,
985973
'copy': ToolCopyToClipboardBase,

‎lib/matplotlib/backends/_backend_tk.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/_backend_tk.py
-7Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_gtk3.py
-24Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt.py
-7Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt5.py
+1-1Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_wx.py
-20Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.