coordinates: should we show the coordinates on the right?
(self, canvas, parent=None, coordinates=True)
| 806 | "qt4_editor_options", "edit_parameters")) |
| 807 | |
| 808 | def __init__(self, canvas, parent=None, coordinates=True): |
| 809 | """coordinates: should we show the coordinates on the right?""" |
| 810 | QtWidgets.QToolBar.__init__(self, parent) |
| 811 | self.setAllowedAreas(QtCore.Qt.ToolBarArea( |
| 812 | _to_int(QtCore.Qt.ToolBarArea.TopToolBarArea) | |
| 813 | _to_int(QtCore.Qt.ToolBarArea.BottomToolBarArea))) |
| 814 | self.coordinates = coordinates |
| 815 | self._actions = {} # mapping of toolitem method names to QActions. |
| 816 | self._subplot_dialog = None |
| 817 | |
| 818 | for text, tooltip_text, image_file, callback in self.toolitems: |
| 819 | if text is None: |
| 820 | self.addSeparator() |
| 821 | else: |
| 822 | slot = getattr(self, callback) |
| 823 | # https://bugreports.qt.io/browse/PYSIDE-2512 |
| 824 | slot = functools.wraps(slot)(functools.partial(slot)) |
| 825 | slot = QtCore.Slot()(slot) |
| 826 | |
| 827 | a = self.addAction(self._icon(image_file + '.png'), |
| 828 | text, slot) |
| 829 | self._actions[callback] = a |
| 830 | if callback in ['zoom', 'pan']: |
| 831 | a.setCheckable(True) |
| 832 | if tooltip_text is not None: |
| 833 | a.setToolTip(tooltip_text) |
| 834 | |
| 835 | # Add the (x, y) location widget at the right side of the toolbar |
| 836 | # The stretch factor is 1 which means any resizing of the toolbar |
| 837 | # will resize this label instead of the buttons. |
| 838 | if self.coordinates: |
| 839 | self.locLabel = QtWidgets.QLabel("", self) |
| 840 | self.locLabel.setAlignment(QtCore.Qt.AlignmentFlag( |
| 841 | _to_int(QtCore.Qt.AlignmentFlag.AlignRight) | |
| 842 | _to_int(QtCore.Qt.AlignmentFlag.AlignVCenter))) |
| 843 | |
| 844 | self.locLabel.setSizePolicy(QtWidgets.QSizePolicy( |
| 845 | QtWidgets.QSizePolicy.Policy.Expanding, |
| 846 | QtWidgets.QSizePolicy.Policy.Ignored, |
| 847 | )) |
| 848 | labelAction = self.addWidget(self.locLabel) |
| 849 | labelAction.setVisible(True) |
| 850 | |
| 851 | NavigationToolbar2.__init__(self, canvas) |
| 852 | |
| 853 | def _icon(self, name): |
| 854 | """ |