8000 Dedupe timer attribute docs. by anntzer · Pull Request #16500 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Dedupe timer attribute docs. #16500

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 14, 2020
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
Fail 8000 ed to load files.
Loading
Diff view
Diff view
40 changes: 16 additions & 24 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,34 +1044,24 @@ class itself will store the flag and the ``_on_timer`` method should be

- ``_on_timer``: The internal function that any timer object should call,
which will handle the task of running all callbacks that have been set.

Attributes
----------
interval : int, default: 1000ms
The time between timer events in milliseconds.
single_shot : bool, default: False
Whether this timer should operate as single shot (run once and then
stop).
callbacks : List[Tuple[callable, Tuple, Dict]]
Stores list of (func, args, kwargs) tuples that will be called upon
timer events. This list can be manipulated directly, or the
functions `add_callback` and `remove_callback` can be used.
"""

def __init__(self, interval=None, callbacks=None):
#Initialize empty callbacks list and setup default settings if necssary
if callbacks is None:
self.callbacks = []
else:
self.callbacks = callbacks.copy()

if interval is None:
self._interval = 1000
else:
self._interval = interval

"""
Parameters
----------
interval : int, default: 1000ms
The time between timer events in milliseconds. Will be stored as
``timer.interval``.
callbacks : List[Tuple[callable, Tuple, Dict]]
List of (func, args, kwargs) tuples that will be called upon
timer events. This list is accessible as ``timer.callbacks`` and
can be manipulated directly, or the functions `add_callback` and
`remove_callback` can be used.
"""
self.callbacks = [] if callbacks is None else callbacks.copy()
self._interval = 1000 if interval is None else interval
self._single = False

# Default attribute for holding the GUI-specific timer object
self._timer = None

Expand Down Expand Up @@ -1105,6 +1095,7 @@ def _timer_stop(self):

@property
def interval(self):
"""The time between timer events, in milliseconds."""
return self._interval

@interval.setter
Expand All @@ -1117,6 +1108,7 @@ def interval(self, interval):

@property
def single_shot(self):
"""Whether this timer should stop after a single run."""
return self._single

@single_shot.setter
Expand Down
16 changes: 1 addition & 15 deletions lib/matplotlib/backends/_backend_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,8 @@ def blit(photoimage, aggimage, offsets, bbox=None):


class TimerTk(TimerBase):
"""
Subclass of :class:`backend_bases.TimerBase` that uses Tk's timer events.
"""Subclass of `backend_bases.TimerBase` using Tk timer events."""

Attributes
----------
interval : int, default: 1000ms
The time between timer events in milliseconds.
single_shot : bool, default: False
Whether this timer should operate as single shot (run once and then
stop).
callbacks : list
Stores list of (func, args) tuples that will be called upon timer
events. This list can be manipulated directly, or the functions
`add_callback` and `remove_callback` can be used.

"""
def __init__(self, parent, *args, **kwargs):
TimerBase.__init__(self, *args, **kwargs)
self.parent = parent
Expand Down
16 changes: 1 addition & 15 deletions lib/matplotlib/backends/backend_gtk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,7 @@


class TimerGTK3(TimerBase):
"""
Subclass of `.TimerBase` using GTK3 for timer events.

Attributes
----------
interval : int, default: 1000ms
The time between timer events in milliseconds.
single_shot : bool, default: False
Whether this timer should operate as single shot (run once and then
stop).
callbacks : list
Stores list of (func, args) tuples that will be called upon timer
events. This list can be manipulated directly, or the functions
`add_callback` and `remove_callback` can be used.
"""
"""Subclass of `.TimerBase` using GTK3 timer events."""

def _timer_start(self):
# Need to stop it, otherwise we potentially leak a timer id that will
Expand Down
17 changes: 1 addition & 16 deletions lib/matplotlib/backends/backend_macosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,7 @@


class TimerMac(_macosx.Timer, TimerBase):
"""
Subclass of `.TimerBase` that uses CoreFoundation run loops for timer
events.

Attributes
----------
interval : int, default: 1000ms
The time between timer events in milliseconds.
single_shot : bool, default: False
Whether this timer should operate as single shot (run once and then
stop).
callbacks : list
Stores list of (func, args) tuples that will be called upon timer
events. This list can be manipulated directly, or the functions
`add_callback` and `remove_callback` can be used.
"""
"""Subclass of `.TimerBase` using CFRunLoop timer events."""
# completely implemented at the C-level (in _macosx.Timer)


Expand Down
17 changes: 1 addition & 16 deletions lib/matplotlib/backends/backend_qt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,25 +175,10 @@ def wrapper(self, *args, **kwargs):


class TimerQT(TimerBase):
"""
Subclass of `.TimerBase` that uses Qt timer events.

Attributes
----------
interval : int, default: 1000ms
The time between timer events in milliseconds.
single_shot : bool, default: False
Whether this timer should operate as single shot (run once and then
stop).
callbacks : list
Stores list of (func, args) tuples that will be called upon timer
events. This list can be manipulated directly, or the functions
`add_callback` and `remove_callback` can be used.
"""
"""Subclass of `.TimerBase` using QTimer events."""

def __init__(self, *args, **kwargs):
TimerBase.__init__(self, *args, **kwargs)

# Create a new timer and connect the timeout() signal to the
# _on_timer method.
self._timer = QtCore.QTimer()
Expand Down
16 changes: 1 addition & 15 deletions lib/matplotlib/backends/backend_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,7 @@ def error_msg_wx(msg, parent=None):


class TimerWx(TimerBase):
"""
Subclass of `.TimerBase` that uses WxTimer events.

Attributes
----------
interval : int, default: 1000ms
The time between timer events in milliseconds.
single_shot : bool, default: False
Whether this timer should operate as single shot (run once and then
stop).
callbacks : list
Stores list of (func, args) tuples that will be called upon timer
events. This list can be manipulated directly, or the functions
`add_callback` and `remove_callback` can be used.
"""
"""Subclass of `.TimerBase` using wx.Timer events."""

def __init__(self, *args, **kwargs):
TimerBase.__init__(self, *args, **kwargs)
Expand Down
0