(self)
| 1577 | return self.text_disp.get_text() |
| 1578 | |
| 1579 | def _rendercursor(self): |
| 1580 | # this is a hack to figure out where the cursor should go. |
| 1581 | # we draw the text up to where the cursor should go, measure |
| 1582 | # and save its dimensions, draw the real text, then put the cursor |
| 1583 | # at the saved dimensions |
| 1584 | |
| 1585 | # This causes a single extra draw if the figure has never been rendered |
| 1586 | # yet, which should be fine as we're going to repeatedly re-render the |
| 1587 | # figure later anyways. |
| 1588 | fig = self.ax.get_figure(root=True) |
| 1589 | if fig._get_renderer() is None: |
| 1590 | fig.canvas.draw() |
| 1591 | |
| 1592 | text = self.text_disp.get_text() # Save value before overwriting it. |
| 1593 | widthtext = text[:self.cursor_index] |
| 1594 | |
| 1595 | bb_text = self.text_disp.get_window_extent() |
| 1596 | self.text_disp.set_text(widthtext or ",") |
| 1597 | bb_widthtext = self.text_disp.get_window_extent() |
| 1598 | |
| 1599 | if bb_text.y0 == bb_text.y1: # Restoring the height if no text. |
| 1600 | bb_text.y0 -= bb_widthtext.height / 2 |
| 1601 | bb_text.y1 += bb_widthtext.height / 2 |
| 1602 | elif not widthtext: # Keep width to 0. |
| 1603 | bb_text.x1 = bb_text.x0 |
| 1604 | else: # Move the cursor using width of bb_widthtext. |
| 1605 | bb_text.x1 = bb_text.x0 + bb_widthtext.width |
| 1606 | |
| 1607 | self.cursor.set( |
| 1608 | segments=[[(bb_text.x1, bb_text.y0), (bb_text.x1, bb_text.y1)]], |
| 1609 | visible=True) |
| 1610 | self.text_disp.set_text(text) |
| 1611 | |
| 1612 | fig.canvas.draw() |
| 1613 | |
| 1614 | @_call_with_reparented_event |
| 1615 | def _release(self, event): |
no test coverage detected