Start a blocking event loop. Such an event loop is used by interactive functions, such as `~.Figure.ginput` and `~.Figure.waitforbuttonpress`, to wait for events. The event loop blocks until a callback function triggers `stop_event_loop`, or *timeou
(self, timeout=0)
| 2435 | """ |
| 2436 | |
| 2437 | def start_event_loop(self, timeout=0): |
| 2438 | """ |
| 2439 | Start a blocking event loop. |
| 2440 | |
| 2441 | Such an event loop is used by interactive functions, such as |
| 2442 | `~.Figure.ginput` and `~.Figure.waitforbuttonpress`, to wait for |
| 2443 | events. |
| 2444 | |
| 2445 | The event loop blocks until a callback function triggers |
| 2446 | `stop_event_loop`, or *timeout* is reached. |
| 2447 | |
| 2448 | If *timeout* is 0 or negative, never timeout. |
| 2449 | |
| 2450 | Only interactive backends need to reimplement this method and it relies |
| 2451 | on `flush_events` being properly implemented. |
| 2452 | |
| 2453 | Interactive backends should implement this in a more native way. |
| 2454 | """ |
| 2455 | if timeout <= 0: |
| 2456 | timeout = np.inf |
| 2457 | timestep = 0.01 |
| 2458 | counter = 0 |
| 2459 | self._looping = True |
| 2460 | while self._looping and counter * timestep < timeout: |
| 2461 | self.flush_events() |
| 2462 | time.sleep(timestep) |
| 2463 | counter += 1 |
| 2464 | |
| 2465 | def stop_event_loop(self): |
| 2466 | """ |
no test coverage detected