MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / blocking_input_loop

Function blocking_input_loop

lib/matplotlib/_blocking_input.py:1–30  ·  view source on GitHub ↗

Run *figure*'s event loop while listening to interactive events. The events listed in *event_names* are passed to *handler*. This function is used to implement `.Figure.waitforbuttonpress`, `.Figure.ginput`, and `.Axes.clabel`. Parameters ---------- figure : `~matplot

(figure, event_names, timeout, handler)

Source from the content-addressed store, hash-verified

1def blocking_input_loop(figure, event_names, timeout, handler):
2 """
3 Run *figure*'s event loop while listening to interactive events.
4
5 The events listed in *event_names* are passed to *handler*.
6
7 This function is used to implement `.Figure.waitforbuttonpress`,
8 `.Figure.ginput`, and `.Axes.clabel`.
9
10 Parameters
11 ----------
12 figure : `~matplotlib.figure.Figure`
13 event_names : list of str
14 The names of the events passed to *handler*.
15 timeout : float
16 If positive, the event loop is stopped after *timeout* seconds.
17 handler : Callable[[Event], Any]
18 Function called for each event; it can force an early exit of the event
19 loop by calling ``canvas.stop_event_loop()``.
20 """
21 if figure.canvas.manager:
22 figure.show() # Ensure that the figure is shown if we are managing it.
23 # Connect the events to the on_event function call.
24 cids = [figure.canvas.mpl_connect(name, handler) for name in event_names]
25 try:
26 figure.canvas.start_event_loop(timeout) # Start event loop.
27 finally: # Run even on exception like ctrl-c.
28 # Disconnect the callbacks.
29 for cid in cids:
30 figure.canvas.mpl_disconnect(cid)

Callers

nothing calls this directly

Calls 4

mpl_connectMethod · 0.80
mpl_disconnectMethod · 0.80
showMethod · 0.45
start_event_loopMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…