| 1630 | @pytest.mark.skipif(sys.platform == 'emscripten', |
| 1631 | reason='emscripten does not support threads') |
| 1632 | def test_ginput(recwarn): # recwarn undoes warn filters at exit. |
| 1633 | warnings.filterwarnings("ignore", "cannot show the figure") |
| 1634 | fig, ax = plt.subplots() |
| 1635 | trans = ax.transData.transform |
| 1636 | |
| 1637 | def single_press(): |
| 1638 | MouseEvent("button_press_event", fig.canvas, *trans((.1, .2)), 1)._process() |
| 1639 | |
| 1640 | Timer(.1, single_press).start() |
| 1641 | assert fig.ginput() == [(.1, .2)] |
| 1642 | |
| 1643 | def multi_presses(): |
| 1644 | MouseEvent("button_press_event", fig.canvas, *trans((.1, .2)), 1)._process() |
| 1645 | KeyEvent("key_press_event", fig.canvas, "backspace")._process() |
| 1646 | MouseEvent("button_press_event", fig.canvas, *trans((.3, .4)), 1)._process() |
| 1647 | MouseEvent("button_press_event", fig.canvas, *trans((.5, .6)), 1)._process() |
| 1648 | MouseEvent("button_press_event", fig.canvas, *trans((0, 0)), 2)._process() |
| 1649 | |
| 1650 | Timer(.1, multi_presses).start() |
| 1651 | np.testing.assert_allclose(fig.ginput(3), [(.3, .4), (.5, .6)]) |
| 1652 | |
| 1653 | |
| 1654 | @pytest.mark.skipif(sys.platform == 'emscripten', |