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

Skip to content

Commit adb8589

Browse files
committed
Also handle the Cairo backends.
The wait cursor is not animated, though.
1 parent 004bf60 commit adb8589

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lib/matplotlib/backends/backend_gtk.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ def fn_name(): return sys._getframe(1).f_code.co_name
2929

3030
import matplotlib
3131
from matplotlib._pylab_helpers import Gcf
32-
from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \
33-
FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors, TimerBase
32+
from matplotlib.backend_bases import (
33+
RendererBase, GraphicsContextBase, FigureManagerBase, FigureCanvasBase,
34+
NavigationToolbar2, TimerBase, cursors)
3435
from matplotlib.backend_bases import ShowBase
3536

3637
from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK
@@ -441,6 +442,9 @@ def expose_event(self, widget, event):
441442
"""
442443
if _debug: print('FigureCanvasGTK.%s' % fn_name())
443444

445+
toolbar = self.toolbar
446+
if toolbar:
447+
toolbar.set_cursor(cursors.WAIT)
444448
if GTK_WIDGET_DRAWABLE(self):
445449
if self._need_redraw:
446450
x, y, w, h = self.allocation
@@ -451,6 +455,8 @@ def expose_event(self, widget, event):
451455
x, y, w, h = event.area
452456
self.window.draw_drawable (self.style.fg_gc[self.state],
453457
self._pixmap, x, y, x, y, w, h)
458+
if toolbar:
459+
toolbar.set_cursor(cursors.POINTER)
454460
return False # finish event propagation?
455461

456462
filetypes = FigureCanvasBase.filetypes.copy()

lib/matplotlib/backends/backend_gtk3cairo.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
import six
55

6-
from . import backend_gtk3
7-
from . import backend_cairo
6+
from . import backend_cairo, backend_gtk3
87
from .backend_cairo import cairo, HAS_CAIRO_CFFI
8+
from matplotlib.backend_bases import cursors
99
from matplotlib.figure import Figure
1010

1111
class RendererGTK3Cairo(backend_cairo.RendererCairo):
@@ -39,10 +39,15 @@ def on_draw_event(self, widget, ctx):
3939
# the _need_redraw flag doesnt work. it sometimes prevents
4040
# the rendering and leaving the canvas blank
4141
#if self._need_redraw:
42+
toolbar = self.toolbar
43+
if toolbar:
44+
toolbar.set_cursor(cursors.WAIT)
4245
self._renderer.set_context(ctx)
4346
allocation = self.get_allocation()
4447
x, y, w, h = allocation.x, allocation.y, allocation.width, allocation.height
4548
self._render_figure(w, h)
49+
if toolbar:
50+
toolbar.set_cursor(cursors.POINTER)
4651
#self._need_redraw = False
4752

4853
return False # finish event propagation?

0 commit comments

Comments
 (0)