Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitfe0095e

Browse files
authored
Merge pull request#6603 from anntzer/waitcursor-while-redrawing
Switch the cursor to a busy cursor while redrawing.
2 parentsefb030d +d1516e6 commitfe0095e

File tree

9 files changed

+38
-10
lines changed

9 files changed

+38
-10
lines changed

‎lib/matplotlib/backend_bases.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,7 +2806,8 @@ def __init__(self, canvas):
28062806
self._idPress=None
28072807
self._idRelease=None
28082808
self._active=None
2809-
self._lastCursor=None
2809+
# This cursor will be set after the initial draw.
2810+
self._lastCursor=cursors.POINTER
28102811
self._init_toolbar()
28112812
self._idDrag=self.canvas.mpl_connect(
28122813
'motion_notify_event',self.mouse_move)
@@ -2892,14 +2893,13 @@ def _set_cursor(self, event):
28922893
self.set_cursor(cursors.POINTER)
28932894
self._lastCursor=cursors.POINTER
28942895
else:
2895-
ifself._active=='ZOOM':
2896-
ifself._lastCursor!=cursors.SELECT_REGION:
2897-
self.set_cursor(cursors.SELECT_REGION)
2898-
self._lastCursor=cursors.SELECT_REGION
2896+
if(self._active=='ZOOM'
2897+
andself._lastCursor!=cursors.SELECT_REGION):
2898+
self.set_cursor(cursors.SELECT_REGION)
2899+
self._lastCursor=cursors.SELECT_REGION
28992900
elif (self._active=='PAN'and
29002901
self._lastCursor!=cursors.MOVE):
29012902
self.set_cursor(cursors.MOVE)
2902-
29032903
self._lastCursor=cursors.MOVE
29042904

29052905
defmouse_move(self,event):
@@ -3189,6 +3189,11 @@ def save_figure(self, *args):
31893189

31903190
defset_cursor(self,cursor):
31913191
"""Set the current cursor to one of the :class:`Cursors` enums values.
3192+
3193+
If required by the backend, this method should trigger an update in
3194+
the backend event loop after the cursor is set, as this method may be
3195+
called e.g. before a long-running task during which the GUI is not
3196+
updated.
31923197
"""
31933198

31943199
defupdate(self):

‎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
classCursors(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
frommathimportradians,cos,sin
3131
frommatplotlibimportverbose,rcParams,__version__
3232
frommatplotlib.backend_basesimport (
33-
_Backend,FigureCanvasBase,FigureManagerBase,RendererBase)
33+
_Backend,FigureCanvasBase,FigureManagerBase,RendererBase,cursors)
3434
frommatplotlib.cbookimportmaxdict
3535
frommatplotlib.figureimportFigure
3636
frommatplotlib.font_managerimportfindfont,get_font
@@ -423,9 +423,14 @@ def draw(self):
423423
# acquire a lock on the shared font cache
424424
RendererAgg.lock.acquire()
425425

426+
toolbar=self.toolbar
426427
try:
428+
iftoolbar:
429+
toolbar.set_cursor(cursors.WAIT)
427430
self.figure.draw(self.renderer)
428431
finally:
432+
iftoolbar:
433+
toolbar.set_cursor(toolbar._lastCursor)
429434
RendererAgg.lock.release()
430435

431436
defget_renderer(self,cleared=False):

‎lib/matplotlib/backends/backend_gtk.py

Lines changed: 7 additions & 1 deletion
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
@@ -386,16 +387,20 @@ def _render_figure(self, pixmap, width, height):
386387
defexpose_event(self,widget,event):
387388
"""Expose_event for all GTK backends. Should not be overridden.
388389
"""
390+
toolbar=self.toolbar
391+
iftoolbar:
392+
toolbar.set_cursor(cursors.WAIT)
389393
ifGTK_WIDGET_DRAWABLE(self):
390394
ifself._need_redraw:
391395
x,y,w,h=self.allocation
392396
self._pixmap_prepare (w,h)
393397
self._render_figure(self._pixmap,w,h)
394398
self._need_redraw=False
395-
396399
x,y,w,h=event.area
397400
self.window.draw_drawable (self.style.fg_gc[self.state],
398401
self._pixmap,x,y,x,y,w,h)
402+
iftoolbar:
403+
toolbar.set_cursor(toolbar._lastCursor)
399404
returnFalse# finish event propagation?
400405

401406
filetypes=FigureCanvasBase.filetypes.copy()
@@ -619,6 +624,7 @@ def set_message(self, s):
619624

620625
defset_cursor(self,cursor):
621626
self.canvas.window.set_cursor(cursord[cursor])
627+
gtk.main_iteration()
622628

623629
defrelease(self,event):
624630
try:delself._pixmapBack

‎lib/matplotlib/backends/backend_gtk3.py

Lines changed: 2 additions & 1 deletion
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

@@ -499,7 +500,7 @@ def set_message(self, s):
499500

500501
defset_cursor(self,cursor):
501502
self.canvas.get_property("window").set_cursor(cursord[cursor])
502-
#self.canvas.set_cursor(cursord[cursor])
503+
Gtk.main_iteration()
503504

504505
defrelease(self,event):
505506
try:delself._pixmapBack

‎lib/matplotlib/backends/backend_gtk3cairo.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .importbackend_cairo,backend_gtk3
77
from .backend_cairoimportcairo,HAS_CAIRO_CFFI
88
from .backend_gtk3import_BackendGTK3
9+
frommatplotlib.backend_basesimportcursors
910
frommatplotlib.figureimportFigure
1011

1112

@@ -35,10 +36,15 @@ def _render_figure(self, width, height):
3536
defon_draw_event(self,widget,ctx):
3637
""" GtkDrawable draw event, like expose_event in GTK 2.X
3738
"""
39+
toolbar=self.toolbar
40+
iftoolbar:
41+
toolbar.set_cursor(cursors.WAIT)
3842
self._renderer.set_context(ctx)
3943
allocation=self.get_allocation()
4044
x,y,w,h=allocation.x,allocation.y,allocation.width,allocation.height
4145
self._render_figure(w,h)
46+
iftoolbar:
47+
toolbar.set_cursor(toolbar._lastCursor)
4248
returnFalse# finish event propagation?
4349

4450

‎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: 2 additions & 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

@@ -697,6 +698,7 @@ def release(self, event):
697698

698699
defset_cursor(self,cursor):
699700
self.window.configure(cursor=cursord[cursor])
701+
self.window.update_idletasks()
700702

701703
def_Button(self,text,file,command,extension='.gif'):
702704
img_file=os.path.join(

‎lib/matplotlib/backends/backend_wx.py

Lines changed: 2 additions & 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

@@ -1594,6 +1595,7 @@ def save_figure(self, *args):
15941595
defset_cursor(self,cursor):
15951596
cursor=wxc.Cursor(cursord[cursor])
15961597
self.canvas.SetCursor(cursor)
1598+
self.canvas.Update()
15971599

15981600
defrelease(self,event):
15991601
try:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp