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

Skip to content

Inherit some docstrings in backend code. #13357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down
18 changes: 3 additions & 15 deletions lib/matplotlib/backends/_backend_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()


Expand Down
17 changes: 4 additions & 13 deletions lib/matplotlib/backends/backend_gtk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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()
Expand Down
16 changes: 3 additions & 13 deletions lib/matplotlib/backends/backend_macosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)


Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/backends/backend_nbagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
20 changes: 4 additions & 16 deletions lib/matplotlib/backends/backend_qt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()

Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/backends/backend_webagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def show(self):
show()

def new_timer(self, *args, **kwargs):
# docstring inherited
return TimerTornado(*args, **kwargs)


Expand Down
62 changes: 10 additions & 52 deletions lib/matplotlib/backends/backend_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down