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

Method handler

lib/matplotlib/figure.py:3569–3601  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

3567 marks = []
3568
3569 def handler(event):
3570 is_button = event.name == "button_press_event"
3571 is_key = event.name == "key_press_event"
3572 # Quit (even if not in infinite mode; this is consistent with
3573 # MATLAB and sometimes quite useful, but will require the user to
3574 # test how many points were actually returned before using data).
3575 if (is_button and event.button == mouse_stop
3576 or is_key and event.key in ["escape", "enter"]):
3577 self.canvas.stop_event_loop()
3578 # Pop last click.
3579 elif (is_button and event.button == mouse_pop
3580 or is_key and event.key in ["backspace", "delete"]):
3581 if clicks:
3582 clicks.pop()
3583 if show_clicks:
3584 marks.pop().remove()
3585 self.canvas.draw()
3586 # Add new click.
3587 elif (is_button and event.button == mouse_add
3588 # On macOS/gtk, some keys return None.
3589 or is_key and event.key is not None):
3590 if event.inaxes:
3591 clicks.append((event.xdata, event.ydata))
3592 _log.info("input %i: %f, %f",
3593 len(clicks), event.xdata, event.ydata)
3594 if show_clicks:
3595 line = mpl.lines.Line2D([event.xdata], [event.ydata],
3596 marker="+", color="r")
3597 event.inaxes.add_line(line)
3598 marks.append(line)
3599 self.canvas.draw()
3600 if len(clicks) == n and n > 0:
3601 self.canvas.stop_event_loop()
3602
3603 _blocking_input.blocking_input_loop(
3604 self, ["button_press_event", "key_press_event"], timeout, handler)

Callers

nothing calls this directly

Calls 5

add_lineMethod · 0.80
stop_event_loopMethod · 0.45
popMethod · 0.45
removeMethod · 0.45
drawMethod · 0.45

Tested by

no test coverage detected