diff --git a/lib/matplotlib/_blocking_input.py b/lib/matplotlib/_blocking_input.py index 5842f7f3fb30..45f077571443 100644 --- a/lib/matplotlib/_blocking_input.py +++ b/lib/matplotlib/_blocking_input.py @@ -18,7 +18,7 @@ def blocking_input_loop(figure, event_names, timeout, handler): Function called for each event; it can force an early exit of the event loop by calling ``canvas.stop_event_loop()``. """ - if hasattr(figure.canvas, "manager"): + if figure.canvas.manager: figure.show() # Ensure that the figure is shown if we are managing it. # Connect the events to the on_event function call. cids = [figure.canvas.mpl_connect(name, handler) for name in event_names] diff --git a/lib/matplotlib/blocking_input.py b/lib/matplotlib/blocking_input.py index 4a0082e24043..f59a54ff7343 100644 --- a/lib/matplotlib/blocking_input.py +++ b/lib/matplotlib/blocking_input.py @@ -83,7 +83,7 @@ def __call__(self, n=1, timeout=30): self.n = n self.events = [] - if hasattr(self.fig.canvas, "manager"): + if self.figure.canvas.manager: # Ensure that the figure is shown, if we are managing it. self.fig.show() # Connect the events to the on_event function call.