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

Skip to content

Commit 004bf60

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 75fde88 commit 004bf60

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
@@ -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: 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 (RendererBase, FigureManagerBase,
33-
FigureCanvasBase)
33+
FigureCanvasBase, cursors)
3434
from matplotlib.cbook import maxdict, restrict_dict
3535
from matplotlib.figure import Figure
3636
from matplotlib.font_manager import findfont, get_font
@@ -471,9 +471,14 @@ def draw(self):
471471
# acquire a lock on the shared font cache
472472
RendererAgg.lock.acquire()
473473

474+
toolbar = self.toolbar
474475
try:
476+
if toolbar:
477+
toolbar.set_cursor(cursors.WAIT)
475478
self.figure.draw(self.renderer)
476479
finally:
480+
if toolbar:
481+
toolbar.set_cursor(cursors.POINTER)
477482
RendererAgg.lock.release()
478483

479484
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
@@ -59,6 +59,7 @@ def fn_name(): return sys._getframe(1).f_code.co_name
5959
cursors.HAND : gdk.Cursor(gdk.HAND2),
6060
cursors.POINTER : gdk.Cursor(gdk.LEFT_PTR),
6161
cursors.SELECT_REGION : gdk.Cursor(gdk.TCROSS),
62+
cursors.WAIT : gdk.Cursor(gdk.WATCH),
6263
}
6364

6465
# 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
@@ -100,6 +100,7 @@ def fn_name():
100100
cursors.HAND: QtCore.Qt.PointingHandCursor,
101101
cursors.POINTER: QtCore.Qt.ArrowCursor,
102102
cursors.SELECT_REGION: QtCore.Qt.CrossCursor,
103+
cursors.WAIT: QtCore.Qt.WaitCursor,
103104
}
104105

105106

lib/matplotlib/backends/backend_tkagg.py

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

5152

lib/matplotlib/backends/backend_wx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,7 @@ def updateButtonText(self, lst):
15481548
cursors.HAND: wx.CURSOR_HAND,
15491549
cursors.POINTER: wx.CURSOR_ARROW,
15501550
cursors.SELECT_REGION: wx.CURSOR_CROSS,
1551+
cursors.WAIT: wx.CURSOR_WAIT,
15511552
}
15521553

15531554

0 commit comments

Comments
 (0)