diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index cfa4e5e79454..3f48a1d2025b 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -2155,7 +2155,8 @@ def new_timer(self, *args, **kwargs): return TimerBase(*args, **kwargs) def flush_events(self): - """Flush the GUI events for the figure. + """ + Flush the GUI events for the figure. Interactive backends need to reimplement this method. """ diff --git a/lib/matplotlib/backends/_backend_tk.py b/lib/matplotlib/backends/_backend_tk.py index 8b9291fac66c..3635de2b4af3 100644 --- a/lib/matplotlib/backends/_backend_tk.py +++ b/lib/matplotlib/backends/_backend_tk.py @@ -324,7 +324,7 @@ def _update_pointer_position(self, guiEvent=None): self.leave_notify_event(guiEvent) def draw_idle(self): - """Update the drawing area if idle.""" + # docstring inherited if not self._idle: return @@ -462,23 +462,11 @@ def key_release(self, event): FigureCanvasBase.key_release_event(self, key, guiEvent=event) def new_timer(self, *args, **kwargs): - """ - Creates a new backend-specific subclass of `.backend_bases.Timer`. - This is useful for getting periodic events through the backend's native - event loop. Implemented only for backends with GUIs. - - Other Parameters - ---------------- - interval : scalar - Timer interval in milliseconds - callbacks : list - Sequence of (func, args, kwargs) where ``func(*args, **kwargs)`` - will be executed by the timer every *interval*. - - """ + # docstring inherited return TimerTk(self._tkcanvas, *args, **kwargs) def flush_events(self): + # docstring inherited self._master.update() diff --git a/lib/matplotlib/backends/backend_gtk3.py b/lib/matplotlib/backends/backend_gtk3.py index f8f366095744..7b2ac7d9eead 100644 --- a/lib/matplotlib/backends/backend_gtk3.py +++ b/lib/matplotlib/backends/backend_gtk3.py @@ -292,10 +292,12 @@ def on_draw_event(self, widget, ctx): pass def draw(self): + # docstring inherited if self.is_drawable(): self.queue_draw() def draw_idle(self): + # docstring inherited if self._idle_draw_id != 0: return def idle_draw(*args): @@ -307,22 +309,11 @@ def idle_draw(*args): self._idle_draw_id = GLib.idle_add(idle_draw) def new_timer(self, *args, **kwargs): - """ - Creates a new backend-specific subclass of :class:`backend_bases.Timer`. - This is useful for getting periodic events through the backend's native - event loop. Implemented only for backends with GUIs. - - Other Parameters - ---------------- - interval : scalar - Timer interval in milliseconds - callbacks : list - Sequence of (func, args, kwargs) where ``func(*args, **kwargs)`` - will be executed by the timer every *interval*. - """ + # docstring inherited return TimerGTK3(*args, **kwargs) def flush_events(self): + # docstring inherited Gdk.threads_enter() while Gtk.events_pending(): Gtk.main_iteration() diff --git a/lib/matplotlib/backends/backend_macosx.py b/lib/matplotlib/backends/backend_macosx.py index b19aa18c267d..f88bf2bb8edc 100644 --- a/lib/matplotlib/backends/backend_macosx.py +++ b/lib/matplotlib/backends/backend_macosx.py @@ -82,10 +82,12 @@ def _draw(self): return renderer def draw(self): + # docstring inherited self.invalidate() self.flush_events() def draw_idle(self, *args, **kwargs): + # docstring inherited self.invalidate() def blit(self, bbox=None): @@ -102,19 +104,7 @@ def resize(self, width, height): self.draw_idle() def new_timer(self, *args, **kwargs): - """ - Creates a new backend-specific subclass of `backend_bases.Timer`. - This is useful for getting periodic events through the backend's native - event loop. Implemented only for backends with GUIs. - - Other Parameters - ---------------- - interval : scalar - Timer interval in milliseconds - callbacks : list - Sequence of (func, args, kwargs) where ``func(*args, **kwargs)`` - will be executed by the timer every *interval*. - """ + # docstring inherited return TimerMac(*args, **kwargs) diff --git a/lib/matplotlib/backends/backend_nbagg.py b/lib/matplotlib/backends/backend_nbagg.py index 7ca41a7142fb..b2fae164b55a 100644 --- a/lib/matplotlib/backends/backend_nbagg.py +++ b/lib/matplotlib/backends/backend_nbagg.py @@ -144,6 +144,7 @@ def remove_comm(self, comm_id): class FigureCanvasNbAgg(FigureCanvasWebAggCore): def new_timer(self, *args, **kwargs): + # docstring inherited return TimerTornado(*args, **kwargs) diff --git a/lib/matplotlib/backends/backend_qt5.py b/lib/matplotlib/backends/backend_qt5.py index d6b3e9f9f0ba..f6a9306f54f2 100644 --- a/lib/matplotlib/backends/backend_qt5.py +++ b/lib/matplotlib/backends/backend_qt5.py @@ -448,28 +448,15 @@ def _get_key(self, event): return '+'.join(mods + [key]) def new_timer(self, *args, **kwargs): - """ - Creates a new backend-specific subclass of - :class:`backend_bases.Timer`. This is useful for getting - periodic events through the backend's native event - loop. Implemented only for backends with GUIs. - - Other Parameters - ---------------- - interval : scalar - Timer interval in milliseconds - - callbacks : list - Sequence of (func, args, kwargs) where ``func(*args, **kwargs)`` - will be executed by the timer every *interval*. - - """ + # docstring inherited return TimerQT(*args, **kwargs) def flush_events(self): + # docstring inherited qApp.processEvents() def start_event_loop(self, timeout=0): + # docstring inherited if hasattr(self, "_event_loop") and self._event_loop.isRunning(): raise RuntimeError("Event loop already running") self._event_loop = event_loop = QtCore.QEventLoop() @@ -478,6 +465,7 @@ def start_event_loop(self, timeout=0): event_loop.exec_() def stop_event_loop(self, event=None): + # docstring inherited if hasattr(self, "_event_loop"): self._event_loop.quit() diff --git a/lib/matplotlib/backends/backend_webagg.py b/lib/matplotlib/backends/backend_webagg.py index 087eb7b70243..85c6fe751ea7 100644 --- a/lib/matplotlib/backends/backend_webagg.py +++ b/lib/matplotlib/backends/backend_webagg.py @@ -53,6 +53,7 @@ def show(self): show() def new_timer(self, *args, **kwargs): + # docstring inherited return TimerTornado(*args, **kwargs) diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index 0a45edfbbde0..60ed9e0cf5f7 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -446,11 +446,7 @@ def unselect(self): self.IsSelected = False def set_foreground(self, fg, isRGBA=None): - """ - Set the foreground color. fg can be a matlab format string, a - html hex color string, an rgb unit tuple, or a float between 0 - and 1. In the latter case, grayscale is used. - """ + # docstring inherited # Implementation note: wxPython has a separate concept of pen and # brush - the brush fills any outline trace left by the pen. # Here we set both to the same colour - if a figure is not to be @@ -465,9 +461,7 @@ def set_foreground(self, fg, isRGBA=None): self.unselect() def set_linewidth(self, w): - """ - Set the line width. - """ + # docstring inherited w = float(w) DEBUG_MSG("set_linewidth()", 1, self) self.select() @@ -482,9 +476,7 @@ def set_linewidth(self, w): self.unselect() def set_capstyle(self, cs): - """ - Set the capstyle as a string in ('butt', 'round', 'projecting') - """ + # docstring inherited DEBUG_MSG("set_capstyle()", 1, self) self.select() GraphicsContextBase.set_capstyle(self, cs) @@ -493,9 +485,7 @@ def set_capstyle(self, cs): self.unselect() def set_joinstyle(self, js): - """ - Set the join style to be one of ('miter', 'round', 'bevel') - """ + # docstring inherited DEBUG_MSG("set_joinstyle()", 1, self) self.select() GraphicsContextBase.set_joinstyle(self, js) @@ -662,9 +652,7 @@ def Copy_to_Clipboard(self, event=None): wx.TheClipboard.Flush() def draw_idle(self): - """ - Delay rendering until the GUI is idle. - """ + # docstring inherited DEBUG_MSG("draw_idle()", 1, self) self._isDrawn = False # Force redraw # Triggering a paint event is all that is needed to defer drawing @@ -673,59 +661,28 @@ def draw_idle(self): self.Refresh(eraseBackground=False) def new_timer(self, *args, **kwargs): - """ - Creates a new backend-specific subclass of - :class:`backend_bases.Timer`. This is useful for getting periodic - events through the backend's native event loop. Implemented only - for backends with GUIs. - - Other Parameters - ---------------- - interval : scalar - Timer interval in milliseconds - callbacks : list - Sequence of (func, args, kwargs) where ``func(*args, **kwargs)`` - will be executed by the timer every *interval*. - - """ + # docstring inherited return TimerWx(*args, **kwargs) def flush_events(self): + # docstring inherited wx.Yield() def start_event_loop(self, timeout=0): - """ - Start an event loop. This is used to start a blocking event - loop so that interactive functions, such as ginput and - waitforbuttonpress, can wait for events. This should not be - confused with the main GUI event loop, which is always running - and has nothing to do with this. - - This call blocks until a callback function triggers - stop_event_loop() or *timeout* is reached. If *timeout* is - <=0, never timeout. - - Raises RuntimeError if event loop is already running. - """ + # docstring inherited if hasattr(self, '_event_loop'): raise RuntimeError("Event loop already running") timer = wx.Timer(self, id=wx.ID_ANY) if timeout > 0: timer.Start(timeout * 1000, oneShot=True) self.Bind(wx.EVT_TIMER, self.stop_event_loop, id=timer.GetId()) - # Event loop handler for start/stop event loop self._event_loop = wx.GUIEventLoop() self._event_loop.Run() timer.Stop() def stop_event_loop(self, event=None): - """ - Stop an event loop. This is used to stop a blocking event - loop so that interactive functions, such as ginput and - waitforbuttonpress, can wait for events. - - """ + # docstring inherited if hasattr(self, '_event_loop'): if self._event_loop.IsRunning(): self._event_loop.Exit() @@ -785,6 +742,7 @@ def gui_repaint(self, drawDC=None, origin='WX'): } def print_figure(self, filename, *args, **kwargs): + # docstring inherited super().print_figure(filename, *args, **kwargs) # Restore the current view; this is needed because the artist contains # methods rely on particular attributes of the rendered figure for