Skip to content

Commit a9376df

Browse files
committed
Switch the cursor to a busy cursor while redrawing.
To test, plot e.g. `plot(rand(100000))` and zoom in manually (the redraw should take some time). The cursor should switch to a "busy" cursor (e.g. spinwheel). The switch doesn't seem to happen under the Tk and WX backends, probably due to some event loop intricacies I don't understand.
1 parent 7dd60e9 commit a9376df

File tree

7 files changed

+12
-2
lines changed

7 files changed

+12
-2
lines changed

lib/matplotlib/backend_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
class Cursors(object):
2626
"""Simple namespace for cursor reference"""
27-
HAND, POINTER, SELECT_REGION, MOVE = list(range(4))
27+
HAND, POINTER, SELECT_REGION, MOVE, WAIT = list(range(5))
2828
cursors = Cursors()
2929

3030
# Views positions tool

lib/matplotlib/backends/backend_agg.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from math import radians, cos, sin
3131
from matplotlib import verbose, rcParams, __version__
3232
from matplotlib.backend_bases import (
33-
_Backend, FigureCanvasBase, FigureManagerBase, RendererBase)
33+
_Backend, FigureCanvasBase, FigureManagerBase, RendererBase, cursors)
3434
from matplotlib.cbook import maxdict
3535
from matplotlib.figure import Figure
3636
from matplotlib.font_manager import findfont, get_font
@@ -422,9 +422,14 @@ def draw(self):
422422
# acquire a lock on the shared font cache
423423
RendererAgg.lock.acquire()
424424

425+
toolbar = self.toolbar
425426
try:
427+
if toolbar:
428+
toolbar.set_cursor(cursors.WAIT)
426429
self.figure.draw(self.renderer)
427430
finally:
431+
if toolbar:
432+
toolbar.set_cursor(cursors.POINTER)
428433
RendererAgg.lock.release()
429434

430435
def get_renderer(self, cleared=False):

lib/matplotlib/backends/backend_gtk.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
cursors.HAND : gdk.Cursor(gdk.HAND2),
5555
cursors.POINTER : gdk.Cursor(gdk.LEFT_PTR),
5656
cursors.SELECT_REGION : gdk.Cursor(gdk.TCROSS),
57+
cursors.WAIT : gdk.Cursor(gdk.WATCH),
5758
}
5859

5960
# ref gtk+/gtk/gtkwidget.h

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
cursors.HAND : Gdk.Cursor.new(Gdk.CursorType.HAND2),
5252
cursors.POINTER : Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR),
5353
cursors.SELECT_REGION : Gdk.Cursor.new(Gdk.CursorType.TCROSS),
54+
cursors.WAIT : Gdk.Cursor.new(Gdk.CursorType.WATCH),
5455
}
5556

5657

lib/matplotlib/backends/backend_qt5.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
cursors.HAND: QtCore.Qt.PointingHandCursor,
9191
cursors.POINTER: QtCore.Qt.ArrowCursor,
9292
cursors.SELECT_REGION: QtCore.Qt.CrossCursor,
93+
cursors.WAIT: QtCore.Qt.WaitCursor,
9394
}
9495

9596

lib/matplotlib/backends/backend_tkagg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
cursors.HAND: "hand2",
4646
cursors.POINTER: "arrow",
4747
cursors.SELECT_REGION: "tcross",
48+
cursors.WAIT: "watch",
4849
}
4950

5051

lib/matplotlib/backends/backend_wx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,7 @@ def updateButtonText(self, lst):
14741474
cursors.HAND: wx.CURSOR_HAND,
14751475
cursors.POINTER: wx.CURSOR_ARROW,
14761476
cursors.SELECT_REGION: wx.CURSOR_CROSS,
1477+
cursors.WAIT: wx.CURSOR_WAIT,
14771478
}
14781479

14791480

0 commit comments

Comments
 (0)