Parameters ---------- ax : `~matplotlib.axes.Axes` The `~.axes.Axes` instance the button will be placed into. label : str Label for this text box. initial : str Initial value in the text box. color : :mpltype:`color
(self, ax, label, initial='', *,
color='.95', hovercolor='1', label_pad=.01,
textalignment="left")
| 1513 | """ |
| 1514 | |
| 1515 | def __init__(self, ax, label, initial='', *, |
| 1516 | color='.95', hovercolor='1', label_pad=.01, |
| 1517 | textalignment="left"): |
| 1518 | """ |
| 1519 | Parameters |
| 1520 | ---------- |
| 1521 | ax : `~matplotlib.axes.Axes` |
| 1522 | The `~.axes.Axes` instance the button will be placed into. |
| 1523 | label : str |
| 1524 | Label for this text box. |
| 1525 | initial : str |
| 1526 | Initial value in the text box. |
| 1527 | color : :mpltype:`color` |
| 1528 | The color of the box. |
| 1529 | hovercolor : :mpltype:`color` |
| 1530 | The color of the box when the mouse is over it. |
| 1531 | label_pad : float |
| 1532 | The distance between the label and the right side of the textbox. |
| 1533 | textalignment : {'left', 'center', 'right'} |
| 1534 | The horizontal location of the text. |
| 1535 | """ |
| 1536 | super().__init__(ax) |
| 1537 | |
| 1538 | self._text_position = _api.getitem_checked( |
| 1539 | {"left": 0.05, "center": 0.5, "right": 0.95}, |
| 1540 | textalignment=textalignment) |
| 1541 | |
| 1542 | self.label = ax.text( |
| 1543 | -label_pad, 0.5, label, transform=ax.transAxes, |
| 1544 | verticalalignment='center', horizontalalignment='right') |
| 1545 | |
| 1546 | # TextBox's text object should not parse mathtext at all. |
| 1547 | self.text_disp = self.ax.text( |
| 1548 | self._text_position, 0.5, initial, transform=self.ax.transAxes, |
| 1549 | verticalalignment='center', horizontalalignment=textalignment, |
| 1550 | parse_math=False) |
| 1551 | |
| 1552 | self._observers = cbook.CallbackRegistry(signals=["change", "submit"]) |
| 1553 | |
| 1554 | ax.set( |
| 1555 | xlim=(0, 1), ylim=(0, 1), # s.t. cursor appears from first click. |
| 1556 | navigate=False, facecolor=color, |
| 1557 | xticks=[], yticks=[]) |
| 1558 | |
| 1559 | self.cursor_index = 0 |
| 1560 | |
| 1561 | self.cursor = ax.vlines(0, 0, 0, visible=False, color="k", lw=1, |
| 1562 | transform=mpl.transforms.IdentityTransform()) |
| 1563 | |
| 1564 | self.connect_event('button_press_event', self._click) |
| 1565 | self.connect_event('button_release_event', self._release) |
| 1566 | self.connect_event('motion_notify_event', self._motion) |
| 1567 | self.connect_event('key_press_event', self._keypress) |
| 1568 | self.connect_event('resize_event', self._resize) |
| 1569 | |
| 1570 | self.color = color |
| 1571 | self.hovercolor = hovercolor |
| 1572 |
nothing calls this directly
no test coverage detected