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

Skip to content

Commit 6c8450c

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 6b1adfd commit 6c8450c

File tree

7 files changed

+9
-2
lines changed

7 files changed

+9
-2
lines changed

lib/matplotlib/backend_tools.py

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

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

2929
# Views positions tool

lib/matplotlib/backends/backend_agg.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from math import radians, cos, sin
3030
from matplotlib import verbose, rcParams
3131
from matplotlib.backend_bases import (RendererBase, FigureManagerBase,
32-
FigureCanvasBase)
32+
FigureCanvasBase, cursors)
3333
from matplotlib.cbook import is_string_like, maxdict, restrict_dict
3434
from matplotlib.figure import Figure
3535
from matplotlib.font_manager import findfont, get_font
@@ -461,8 +461,10 @@ def draw(self):
461461
RendererAgg.lock.acquire()
462462

463463
try:
464+
self.toolbar.set_cursor(cursors.WAIT)
464465
self.figure.draw(self.renderer)
465466
finally:
467+
self.toolbar.set_cursor(cursors.POINTER)
466468
RendererAgg.lock.release()
467469

468470
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
@@ -58,6 +58,7 @@ def fn_name(): return sys._getframe(1).f_code.co_name
5858
cursors.HAND : gdk.Cursor(gdk.HAND2),
5959
cursors.POINTER : gdk.Cursor(gdk.LEFT_PTR),
6060
cursors.SELECT_REGION : gdk.Cursor(gdk.TCROSS),
61+
cursors.WAIT : gdk.Cursor(gdk.WATCH),
6162
}
6263

6364
# 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
@@ -55,6 +55,7 @@ def fn_name(): return sys._getframe(1).f_code.co_name
5555
cursors.HAND : Gdk.Cursor.new(Gdk.CursorType.HAND2),
5656
cursors.POINTER : Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR),
5757
cursors.SELECT_REGION : Gdk.Cursor.new(Gdk.CursorType.TCROSS),
58+
cursors.WAIT : Gdk.Cursor.new(Gdk.CursorType.WATCH),
5859
}
5960

6061
def draw_if_interactive():

lib/matplotlib/backends/backend_qt5.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def fn_name():
102102
cursors.HAND: QtCore.Qt.PointingHandCursor,
103103
cursors.POINTER: QtCore.Qt.ArrowCursor,
104104
cursors.SELECT_REGION: QtCore.Qt.CrossCursor,
105+
cursors.WAIT: QtCore.Qt.WaitCursor,
105106
}
106107

107108

lib/matplotlib/backends/backend_tkagg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
cursors.HAND: "hand2",
4848
cursors.POINTER: "arrow",
4949
cursors.SELECT_REGION: "tcross",
50+
cursors.WAIT: "watch",
5051
}
5152

5253

lib/matplotlib/backends/backend_wx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,7 @@ def updateButtonText(self, lst):
15431543
cursors.HAND: wx.CURSOR_HAND,
15441544
cursors.POINTER: wx.CURSOR_ARROW,
15451545
cursors.SELECT_REGION: wx.CURSOR_CROSS,
1546+
cursors.WAIT: wx.CURSOR_WAIT,
15461547
}
15471548

15481549

0 commit comments

Comments
 (0)