diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index bb9b94c23955..bab1f67bab53 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -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 @@ -1105,6 +1095,7 @@ def _timer_stop(self): @property def interval(self): + """The time between timer events, in milliseconds.""" return self._interval @interval.setter @@ -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 diff --git a/lib/matplotlib/backends/_backend_tk.py b/lib/matplotlib/backends/_backend_tk.py index 7afd6298e69b..b9df92ec6402 100644 --- a/lib/matplotlib/backends/_backend_tk.py +++ b/lib/matplotlib/backends/_backend_tk.py @@ -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 diff --git a/lib/matplotlib/backends/backend_gtk3.py b/lib/matplotlib/backends/backend_gtk3.py index 0aac2cac046c..7fd0a3fe4d0b 100644 --- a/lib/matplotlib/backends/backend_gtk3.py +++ b/lib/matplotlib/backends/backend_gtk3.py @@ -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 diff --git a/lib/matplotlib/backends/backend_macosx.py b/lib/matplotlib/backends/backend_macosx.py index eced4dfc622e..b8b66bfd08f5 100644 --- a/lib/matplotlib/backends/backend_macosx.py +++ b/lib/matplotlib/backends/backend_macosx.py @@ -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) diff --git a/lib/matplotlib/backends/backend_qt5.py b/lib/matplotlib/backends/backend_qt5.py index d2b43742ab00..ed738e0e000b 100644 --- a/lib/matplotlib/backends/backend_qt5.py +++ b/lib/matplotlib/backends/backend_qt5.py @@ -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() diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index de7be3db56fb..088789985944 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -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)