Skip to content

Commit 5e3498f

Browse files
committed
Correctly go through property setter when init'ing Timer interval.
The setter casts the interval to an int, which is required at least by the tk backend.
1 parent 53faed9 commit 5e3498f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,8 +1059,9 @@ def __init__(self, interval=None, callbacks=None):
10591059
`remove_callback` can be used.
10601060
"""
10611061
self.callbacks = [] if callbacks is None else callbacks.copy()
1062-
self._interval = 1000 if interval is None else interval
1063-
self._single = False
1062+
# Set .interval and not ._interval to go through the property setter.
1063+
self.interval = 1000 if interval is None else interval
1064+
self.single_shot = False
10641065
# Default attribute for holding the GUI-specific timer object
10651066
self._timer = None
10661067

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def check_alt_backend(alt_backend):
114114
115115
ax.plot([0, 1], [2, 3])
116116
117-
timer = fig.canvas.new_timer(1)
117+
timer = fig.canvas.new_timer(1.) # Test that floats are cast to int as needed.
118118
timer.add_callback(FigureCanvasBase.key_press_event, fig.canvas, "q")
119119
# Trigger quitting upon draw.
120120
fig.canvas.mpl_connect("draw_event", lambda event: timer.start())

0 commit comments

Comments
 (0)