def updateWindowMenu(self): """ Update the `Window` menu. The `Window` menu is dynamic because its content is determined by the currently open views. Because the number of these views or its contents may vary at any moment we must update the `Window` menu every time it is open. For simplicity we don't keep track of changes in the menu content. Instead, we clean and create it from scratch every time it is about to show. """ # Clear the menu and rebuild it from scratch wmenu = self.window_menu wmenu.clear() window_actions = [ 'windowCascade', 'windowTile', 'windowRestoreAll', 'windowMinimizeAll', 'windowClose', 'windowCloseAll', None, 'mdiTabbed', 'windowSeparator' ] vitables.utils.addActions(wmenu, window_actions, self.gui_actions) windows_list = self.workspace.subWindowList() if not windows_list: return # Create actions for the existing views action_group = QtWidgets.QActionGroup(wmenu) wmenu.action_group = action_group counter = 1 for window in windows_list: title = window.windowTitle() if counter < 10: action = wmenu.addAction("&{0:d} {1}".format(counter, title)) wmenu.action_group.addAction(action) elif counter == 10: wmenu.addSeparator() submenu = wmenu.addMenu( translate('VTGUI', "&More...", 'A Windows submenu')) action_subgroup = QtWidgets.QActionGroup(submenu) elif counter < 36: atext = "&{0} {1}".format(chr(counter + ord("@") - 10), title) action = submenu.addAction(atext) action_subgroup.addAction(action) self.window_mapper.setMapping(action, window) action.triggered.connect(self.window_mapper.map) action.setCheckable(True) if self.workspace.activeSubWindow() == window: action.setChecked(True) counter = counter + 1
def _setupFileActions(self): style = self.style() actions = QtWidgets.QActionGroup(self) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogOpenButton) QtWidgets.QAction(icon, self.tr('Open Vector'), actions, objectName='openVectorAction', statusTip=self.tr('Open Vector'), triggered=self.onOpenVector) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogResetButton) QtWidgets.QAction(icon, self.tr('Close All'), actions, objectName='claseAllAction', statusTip=self.tr('Close All'), triggered=self.reset) QtWidgets.QAction(actions).setSeparator(True) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCancelButton) QtWidgets.QAction(icon, self.tr('Exit'), actions, objectName='exitAction', statusTip=self.tr('Exit'), triggered=self.close) return actions
def _setupActions(self): actions = QtWidgets.QActionGroup(self) # Zoom in icon = qtsupport.geticon('zoom-in.svg', 'gsdview') QtWidgets.QAction(icon, self.tr('Zoom In'), actions, objectName='zoomOutAction', statusTip=self.tr('Zoom In'), shortcut=QtGui.QKeySequence(self.tr('Ctrl++')), enabled=False, triggered=lambda: self._zoom(+1)) # Zoom out icon = qtsupport.geticon('zoom-out.svg', 'gsdview') QtWidgets.QAction(icon, self.tr('Zoom Out'), actions, objectName='zoomOutAction', statusTip=self.tr('Zoom Out'), shortcut=QtGui.QKeySequence(self.tr('Ctrl+-')), enabled=False, triggered=lambda: self._zoom(-1)) return actions
def _setupActions(self): style = QtWidgets.QApplication.style() actions = QtWidgets.QActionGroup(self) icon = QtGui.QIcon.fromTheme('go-top') QtWidgets.QAction(icon, self.tr('Move to top'), actions, objectName='moveToTopAction', statusTip=self.tr('Move to top'), shortcut=self.tr('Ctrl+PgUp')) icon = style.standardIcon(QtWidgets.QStyle.SP_ArrowUp) QtWidgets.QAction(icon, self.tr('Move up'), actions, objectName='moveUpAction', statusTip=self.tr('Move up'), shortcut=self.tr('Ctrl+Up')) icon = style.standardIcon(QtWidgets.QStyle.SP_ArrowDown) QtWidgets.QAction(icon, self.tr('Move down'), actions, objectName='moveDownAction', statusTip=self.tr('Move down'), shortcut=self.tr('Ctrl+Down')) icon = QtGui.QIcon.fromTheme('go-bottom') QtWidgets.QAction(icon, self.tr('Move to bottom'), actions, objectName='moveToBottomAction', statusTip=self.tr('Move to bottom'), shortcut=self.tr('Ctrl+PgDown')) icon = QtGui.QIcon.fromTheme('edit-delete') QtWidgets.QAction(icon, self.tr('Remove'), actions, objectName='removeLayerAction', statusTip=self.tr('Remove'), shortcut=self.tr('Del')) icon = QtGui.QIcon.fromTheme('zoom-fit-best') QtWidgets.QAction(icon, self.tr('Show'), actions, objectName='showLayerAction', statusTip=self.tr('Show the layer')) icon = qstype.standardIcon(QtWidgets.QStyle.SP_DialogCloseButton) QtWidgets.QAction(icon, self.tr('Hide'), actions, objectName='hideLayerAction', statusTip=self.tr('Hide the layer')) return actions
def _setupActions(self): actions = QtWidgets.QActionGroup(self) # KML export icon = qtsupport.geticon('area.svg', 'gsdview') QtWidgets.QAction( icon, self.tr('KML export'), actions, objectName='kmlExportAction', statusTip=self.tr('KML export'), triggered=self.exportKML) # Open in google earth icon = qtsupport.geticon('earth.svg', __name__) QtWidgets.QAction( icon, self.tr('Open in Google Earth'), actions, objectName='openInGoogleEarthAction', statusTip=self.tr('Open in Google Earth'), triggered=self.openInGoogleEarth) # Open in google maps icon = qtsupport.geticon('overview.svg', 'gsdview.gdalbackend') QtWidgets.QAction( icon, self.tr('Open in Google Maps'), actions, objectName='openInGoogleMapsAction', statusTip=self.tr('Open in Google Maps'), triggered=self.openInGoogleMaps) return actions
def _setupMajorObjectItemActions(self, actionsgroup=None): if actionsgroup is None: actionsgroup = QtWidgets.QActionGroup(self) # open metadata view icon = qtsupport.geticon('metadata.svg', __name__) QtWidgets.QAction( icon, self.tr('Open &Metadata View'), actionsgroup, objectName='actionOpenItemMetadataView', shortcut=self.tr('Ctrl+M'), toolTip=self.tr('Show metadata in a new window'), statusTip=self.tr('Show metadata in a new window'), triggered=self.openItemMatadataView, enabled=False) # @TODO: remove # show properties # @TODO: standard info icon from gdsview package icon = qtsupport.geticon('info.svg', 'gsdview') QtWidgets.QAction( icon, self.tr('&Show Properties'), actionsgroup, objectName='actionShowItemProperties', shortcut=self.tr('Ctrl+S'), toolTip=self.tr('Show the property dialog for the current item'), statusTip=self.tr('Show the property dialog for the current item'), triggered=self.showItemProperties) return actionsgroup
def __init__(self, title="Subset Update Mode", parent=None): super(EditSubsetModeToolBar, self).__init__(title, parent) spacer = QtWidgets.QWidget() spacer.setMinimumSize(20, 10) spacer.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) self.addWidget(spacer) self.addWidget(QtWidgets.QLabel("Selection Mode:")) self.setIconSize(QtCore.QSize(20, 20)) self._group = QtWidgets.QActionGroup(self) self._modes = {} self._add_actions() self._edit_subset_mode = self.parent()._session.edit_subset_mode self._modes[self._edit_subset_mode.mode].trigger() self._backup_mode = None spacer = QtWidgets.QWidget() spacer.setMinimumSize(20, 10) spacer.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) self.addWidget(spacer)
def _setupActions(self): qstype = QtWidgets.QApplication.style() # Setup actions self.actions = QtWidgets.QActionGroup(self) # Save As icon = qstype.standardIcon(QtWidgets.QStyle.SP_DialogSaveButton) self.actionSaveAs = QtWidgets.QAction( icon, self.tr('&Save As'), self, shortcut=self.tr('Ctrl+S'), statusTip=self.tr('Save text to file'), triggered=self.save) self.actions.addAction(self.actionSaveAs) # Clear icon = QtGui.QIcon.fromTheme('edit-clear') self.actionClear = QtWidgets.QAction( icon, self.tr('&Clear'), self, shortcut=self.tr('Shift+F5'), statusTip=self.tr('Clear the text'), triggered=self.clear) self.actions.addAction(self.actionClear) # Close icon = qstype.standardIcon(QtWidgets.QStyle.SP_DialogCloseButton) self.actionHide = QtWidgets.QAction( icon, self.tr('&Hide'), self, shortcut=self.tr('Ctrl+W'), statusTip=self.tr('Hide the text pane'), triggered=self.paneHideRequest) self.actions.addAction(self.actionHide)
def __init__(self, title="Subset Update Mode", parent=None): super(EditSubsetModeToolBar, self).__init__(title, parent) self._group = QtWidgets.QActionGroup(self) self._modes = {} self._add_actions() self._modes[EditSubsetMode().mode].trigger() self._backup_mode = None
def _setupViewActions(self): style = self.style() actions = QtWidgets.QActionGroup(self) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogResetButton) QtWidgets.QAction( icon, self.tr('Reset'), actions, objectName='resetAction', statusTip=self.tr('Reset'), triggered=self.onReset) QtWidgets.QAction(actions).setSeparator(True) icon = QtGui.QIcon.fromTheme('zoom-in') QtWidgets.QAction( icon, self.tr('Zoom In'), actions, objectName='zoomInAction', statusTip=self.tr('Zoom In'), shortcut=self.tr('Ctrl++'), triggered=lambda: self.graphicsview.scale(1.2, 1.2)) icon = QtGui.QIcon.fromTheme('zoom-out') QtWidgets.QAction( icon, self.tr('Zoom Out'), actions, objectName='zoomOutAction', statusTip=self.tr('Zoom Out'), shortcut=self.tr('Ctrl+-'), triggered=lambda: self.graphicsview.scale(1 / 1.2, 1 / 1.2)) icon = QtGui.QIcon.fromTheme('zoom-original') QtWidgets.QAction( icon, self.tr('Zoom 1:1'), actions, objectName='zoomResetAction', statusTip=self.tr('Zoom 1:1'), triggered=lambda: self.graphicsview.setTransform( QtGui.QTransform(1, 0, 0, -1, 0, 0))) icon = QtGui.QIcon.fromTheme('zoom-fit-best') QtWidgets.QAction( icon, self.tr('Zoom Fit'), actions, objectName='zoomFitAction', statusTip=self.tr('Zoom Fit'), # checkable=True, triggered=lambda: self.graphicsview.fitInView( self.graphicsview.sceneRect(), QtCore.Qt.KeepAspectRatio)) return actions
def __init__(self, parent=None, stdmodes=True, **kwargs): QtCore.QObject.__init__(self, parent, **kwargs) self._moderegistry = [] self.actions = QtWidgets.QActionGroup(self) self.actions.setExclusive(True) if stdmodes: self.registerStandardModes()
def __init__(self, title=_('Encodings'), parent=None, selected_encoding=locale.getpreferredencoding()): super(EncodingsMenu, self).__init__(parent) self.setTitle(title) self._group = QtWidgets.QActionGroup(self) self._edit_action = None self._current_encoding = '' self.current_encoding = selected_encoding
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setWindowTitle('qudi: <INSERT HARDWARE NAME>') # Create main layout and central widget self.main_layout = QtWidgets.QGridLayout() self.main_layout.setColumnStretch(1, 1) self.main_layout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.main_layout.setSizeConstraint(QtWidgets.QLayout.SetFixedSize) widget = QtWidgets.QWidget() widget.setLayout(self.main_layout) widget.setFixedSize(1, 1) self.setCentralWidget(widget) # Create QActions and menu bar menu_bar = QtWidgets.QMenuBar() self.setMenuBar(menu_bar) menu = menu_bar.addMenu('Menu') self.action_close = QtWidgets.QAction('Close Window') self.action_close.setCheckable(False) self.action_close.setIcon( QtGui.QIcon('artwork/icons/oxygen/22x22/application-exit.png')) self.addAction(self.action_close) menu.addAction(self.action_close) menu = menu_bar.addMenu('View') self.action_periodic_state_check = QtWidgets.QAction( 'Periodic State Checking') self.action_periodic_state_check.setCheckable(True) menu.addAction(self.action_periodic_state_check) separator = menu.addSeparator() separator.setText('Switch Appearance') self.switch_view_actions = [ QtWidgets.QAction('use toggle switches'), QtWidgets.QAction('use radio buttons') ] self.switch_view_action_group = QtWidgets.QActionGroup(self) for action in self.switch_view_actions: action.setCheckable(True) self.switch_view_action_group.addAction(action) menu.addAction(action) self.action_view_highlight_state = QtWidgets.QAction( 'highlight state labels') self.action_view_highlight_state.setCheckable(True) menu.addAction(self.action_view_highlight_state) self.action_view_alt_toggle_style = QtWidgets.QAction( 'alternative toggle switch') self.action_view_alt_toggle_style.setCheckable(True) menu.addAction(self.action_view_alt_toggle_style) # close window upon triggering close action self.action_close.triggered.connect(self.close) return
def _setupHelpActions(self): actions = QtWidgets.QActionGroup(self) icon = QtGui.QIcon.fromTheme('dialog-information') QtWidgets.QAction(icon, 'About', actions, triggered=self.about) icon = QtGui.QIcon(':/qtlogo-64') QtWidgets.QAction(icon, 'About Qt', actions, triggered=QtWidgets.QApplication.aboutQt) return actions
def fill_games_menu(self): games_menu = self.m_window.menu_settings.addMenu('&Game') games_group = QtWidgets.QActionGroup(games_menu) for game in Games(): act = QtWidgets.QAction(game['name'], games_group) act.setCheckable(True) act.setData(game) games_menu.addAction(act) if game == self.m_game: Debug.notice('Current game: %s' % self.m_game['name']) act.setChecked(True) games_group.triggered.connect(self.game_changed) games_group.setExclusive(True)
def setupMenu(self): self.statusBar() main_menu = self.menuBar() file_items = [ ("&Load", 'Ctrl+O', 'Open saved configuration.', self.menu_open), ("&Save", 'Ctrl+S', 'Save the current configuration.', self.menu_save), ("Save &as...", 'Ctrl+Shift+S', 'Save the current configuration as...', self.menu_saveas), None, ("&Exit", 'Ctrl+Q', 'Stop acquisition and close the application.', self.menu_exit) ] self.file_menu = main_menu.addMenu("&File") for item in file_items: if item is None: self.file_menu.addSeparator() continue (name, shortcut, tip, slot) = item action = QtWidgets.QAction(name, self) if shortcut is not None: action.setShortcut(shortcut) action.setStatusTip(tip) action.triggered.connect(slot) self.file_menu.addAction(action) self.history_menu = main_menu.addMenu("&History") mode_items = [ ("&Traditional (*.sig)", None, 'GageScope compatible signal acquisition, saved to *.sig files.', self.menu_trad), ("&Segmented (*.h5)", None, 'Segmented signal acquisition, saved to *.h5 files.', self.menu_seg), ] self.mode_menu = main_menu.addMenu("&Mode") mode_group = QtWidgets.QActionGroup(self) action = None for item in mode_items: (name, shortcut, tip, slot) = item action = QtWidgets.QAction(name, self) if shortcut is not None: action.setShortcut(shortcut) action.setStatusTip(tip) action.setCheckable(True) action.triggered.connect(slot) mode_group.addAction(action) self.mode_menu.addAction(action) action.setChecked(True)
def __init__(self, parent=None, init_channel=None): super(NTImage, self).__init__(parent=parent, init_channel=init_channel) self.setLayout(QtWidgets.QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().setSpacing(0) self.scene = QtWidgets.QGraphicsScene(self) self.scene.setBackgroundBrush(QtGui.QColor("black")) self.pixmap_image = QtWidgets.QGraphicsPixmapItem() self.scene.addItem(self.pixmap_image) self.view = QtWidgets.QGraphicsView(self) self.view.setViewport(QtOpenGL.QGLWidget(QtOpenGL.QGLFormat())) self.view.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.view.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.view.viewport().setContentsMargins(0, 0, 0, 0) self.view.setContentsMargins(0, 0, 0, 0) size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) size_policy.setHeightForWidth(True) self.view.setSizePolicy(size_policy) self.view.setScene(self.scene) self.layout().addWidget(self.view) # Make a right-click menu for changing the color map. self.cm_group = QtWidgets.QActionGroup(self) self.cmap_for_action = {} for cm in self.color_maps: action = self.cm_group.addAction(cmap_names[cm]) action.setCheckable(True) self.cmap_for_action[action] = cm self.thread = None self._colormap = None self._data = None self._image = None # Setup the redraw timer. self._needs_redraw = False self._make_colormap(cmaps[PyDMColorMap.Monochrome]) self._redraw_timer = QtCore.QTimer() self._redraw_timer.timeout.connect(self._redraw) self._redraw_rate = 30 self.maxRedrawRate = self._redraw_rate self._redraw_timer.start()
def __init__(self, parent=None): super().__init__(parent) # Actions self.group = QtWidgets.QActionGroup(self) for perspective in Perspective: action = QtWidgets.QAction(perspective.value.upper()) action.setData(perspective) action.setCheckable(True) self.group.addAction(action) self.addAction(action) # Signals self.actionTriggered.connect(self.perspectiveChanged)
def make_toolbar(self): tb = QtWidgets.QToolBar(parent=self) tb.setIconSize(QtCore.QSize(25, 25)) tb.layout().setSpacing(1) tb.setFocusPolicy(Qt.StrongFocus) agroup = QtWidgets.QActionGroup(tb) agroup.setExclusive(True) for (mode_text, mode_icon, mode_cb) in self._mouse_modes(): # TODO: add icons similar to the Matplotlib toolbar action = tb.addAction(mode_icon, mode_text) action.setCheckable(True) action.toggled.connect(mode_cb) agroup.addAction(action) action = tb.addAction(get_icon('glue_move'), "Pan") self.mode_actns['pan'] = action action.setCheckable(True) action.toggled.connect(lambda tf: self.mode_cb('pan', tf)) agroup.addAction(action) icon = QtGui.QIcon(os.path.join(ginga_icon_dir, 'hand_48.png')) action = tb.addAction(icon, "Free Pan") self.mode_actns['freepan'] = action action.setCheckable(True) action.toggled.connect(lambda tf: self.mode_cb('freepan', tf)) agroup.addAction(action) icon = QtGui.QIcon(os.path.join(ginga_icon_dir, 'rotate_48.png')) action = tb.addAction(icon, "Rotate") self.mode_actns['rotate'] = action action.setCheckable(True) action.toggled.connect(lambda tf: self.mode_cb('rotate', tf)) agroup.addAction(action) action = tb.addAction(get_icon('glue_contrast'), "Contrast") self.mode_actns['contrast'] = action action.setCheckable(True) action.toggled.connect(lambda tf: self.mode_cb('contrast', tf)) agroup.addAction(action) icon = QtGui.QIcon(os.path.join(ginga_icon_dir, 'cuts_48.png')) action = tb.addAction(icon, "Cuts") self.mode_actns['cuts'] = action action.setCheckable(True) action.toggled.connect(lambda tf: self.mode_cb('cuts', tf)) agroup.addAction(action) cmap_w = _colormap_mode(self, self.client.set_cmap) tb.addWidget(cmap_w) return tb
def _setupSubDatasetItemActions(self, actionsgroup=None): if actionsgroup is None: actionsgroup = QtWidgets.QActionGroup(self) # open icon = qtsupport.geticon('open.svg', __name__) QtWidgets.QAction( icon, self.tr('Open Sub Dataset'), actionsgroup, objectName='actionOpenSubDatasetItem', shortcut=self.tr('Ctrl+O'), toolTip=self.tr('Open Sub Dataset'), statusTip=self.tr('Open Sub Dataset'), triggered=self.openSubDataset) self._setupDatasetItemActions(actionsgroup) return actionsgroup
def _setupFileActions(self): style = self.style() actions = QtWidgets.QActionGroup(self) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogOpenButton) QtWidgets.QAction(icon, 'Open', actions, triggered=self.openfile) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCloseButton) QtWidgets.QAction(icon, 'Close', actions, triggered=self.scene.clear) QtWidgets.QAction(actions).setSeparator(True) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCancelButton) QtWidgets.QAction(icon, 'Exit', actions, triggered=self.close) return actions
def create_default_actions(self): """ Create default actions that can be used for e.g. toolbars and menus, or triggered manually. """ self.set_splash("Creating plugin actions") self.plugin_manager.create_actions() self.selectable_tools = QtWidgets.QActionGroup(self) self.selectable_tools.setExclusive(True) # Nested docking action ac_nested = QtWidgets.QAction(tr("Nested docking"), self) ac_nested.setStatusTip(tr("Allow nested widget docking")) ac_nested.setCheckable(True) ac_nested.setChecked(self.isDockNestingEnabled()) ac_nested.triggered[bool].connect(self.setDockNestingEnabled) self.actions['nested_docking'] = ac_nested # Tile windows action ac_tile = QtWidgets.QAction(tr("Tile"), self) ac_tile.setStatusTip(tr("Arranges all figures in a tile pattern")) ac_tile.triggered.connect(self.main_frame.tileSubWindows) self.actions['tile_windows'] = ac_tile # Cascade windows action ac_cascade = QtWidgets.QAction(tr("Cascade"), self) ac_cascade.setStatusTip( tr("Arranges all figures in a cascade pattern")) ac_cascade.triggered.connect(self.main_frame.cascadeSubWindows) self.actions['cascade_windows'] = ac_cascade # Close all figures action ac_close_figs = QtWidgets.QAction(tr("Close all"), self) ac_close_figs.setStatusTip(tr("Closes all matplotlib figures")) ac_close_figs.triggered.connect(lambda: matplotlib.pyplot.close("all")) self.actions['close_all_windows'] = ac_close_figs # Reset geometry action ac_reset_layout = QtWidgets.QAction(tr("Reset layout"), self) ac_reset_layout.setStatusTip( tr("Resets layout of toolbars and " "widgets")) ac_reset_layout.triggered.connect(self.reset_geometry) self.actions['reset_layout'] = ac_reset_layout
def _setupHelpActions(self): actions = QtWidgets.QActionGroup(self) icon = QtGui.QIcon.fromTheme('dialog-information') QtWidgets.QAction( icon, self.tr('About'), actions, objectName='aboutAction', statusTip=self.tr('About'), triggered=self.about) icon = QtGui.QIcon(':/qtlogo-64') QtWidgets.QAction( icon, self.tr('About Qt'), actions, objectName='aboutQtAction', statusTip=self.tr('About Qt'), triggered=QtWidgets.QApplication.aboutQt) return actions
def __init__(self, title="Subset mode toolbar", parent=None): super(EditSubsetModeToolBar, self).__init__(title, parent) self.subset_combo = QtWidgets.QComboBox() self.subset_combo.setMinimumContentsLength(10) spacer = QtWidgets.QWidget() spacer.setMinimumSize(10, 10) spacer.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) self.addWidget(spacer) self.addWidget(QtWidgets.QLabel("Active Subset:")) self.addWidget(self.subset_combo) self._label_subset_mode = QtWidgets.QLabel("Mode:") self.addWidget(self._label_subset_mode) self.setIconSize(QtCore.QSize(16, 16)) self._group = QtWidgets.QActionGroup(self) self._modes = {} self._add_actions() self._edit_subset_mode = self.parent()._session.edit_subset_mode self._modes[self._edit_subset_mode.mode].trigger() self._backup_mode = None spacer = QtWidgets.QWidget() spacer.setMinimumSize(20, 10) spacer.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) self.parent()._hub.subscribe(self, EditSubsetMessage, handler=self._update_mode) self.parent()._hub.subscribe(self, SubsetMessage, handler=self._update_subset_combo) self._data_collection = self.parent().data_collection self._update_subset_combo() self.subset_combo.currentIndexChanged.connect( self._on_subset_combo_change) self._update_mode_visibility()
def aboutShowMenu(self): self.menu.clear() self.ag = QtWidgets.QActionGroup(self.menu) self.ag.setExclusive(True) for n, vp in enumerate(self.project.stackup.via_pairs): l1, l2 = vp.layers a1 = QtWidgets.QAction("%d-%d" % (l1.order, l2.order), self.menu) a1.setCheckable(True) a1.setChecked(vp is self.model.current_layer_pair) def closure(vp): def fn(): self.__changed_selected_viapair(vp) return fn a1.triggered.connect(closure(vp)) self.menu.addAction(a1) self.ag.addAction(a1)
def setupToolButtonExtra(self): self.menu = QtWidgets.QMenu() self.ag = QtWidgets.QActionGroup(self.menu) for n in valid_select: a1 = QtWidgets.QAction(select_names[n], self.menu) def closure(n): def fn(): self.__set_version(n) self.toolButton.click() return fn a1.triggered.connect(closure(n)) self.menu.addAction(a1) self.ag.addAction(a1) self.toolButton.setMenu(self.menu) self.__update_icon()
def _setupDatasetItemActions(self, actionsgroup=None): if actionsgroup is None: actionsgroup = QtWidgets.QActionGroup(self) # open RGB # @TODO: find an icon for RGB icon = qtsupport.geticon('rasterband.svg', __name__) QtWidgets.QAction( icon, self.tr('Open as RGB'), actionsgroup, objectName='actionOpenRGBImageView', # shortcut=self.tr('Ctrl+B'), toolTip=self.tr('Display the dataset as an RGB image'), statusTip=self.tr('Open as RGB'), triggered=self.openRGBImageView) # build overviews icon = qtsupport.geticon('overview.svg', __name__) QtWidgets.QAction( icon, self.tr('&Build overviews'), actionsgroup, objectName='actionBuildOverviews', shortcut=self.tr('Ctrl+B'), toolTip=self.tr('Build overviews for all raster bands'), statusTip=self.tr('Build overviews for all raster bands'), triggered=self.buildOverviews) # @TODO: add band, add virtual band, open GCPs view # close icon = qtsupport.geticon('close.svg', 'gsdview') QtWidgets.QAction( icon, self.tr('Close'), actionsgroup, objectName='actionCloseItem', shortcut=self.tr('Ctrl+W'), toolTip=self.tr('Close the current item'), statusTip=self.tr('Close the current item'), triggered=self.closeCurrentItem) self._setupMajorObjectItemActions(actionsgroup) return actionsgroup
def _setupFileActions(self): style = self.style() actions = QtWidgets.QActionGroup(self) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogOpenButton) QtWidgets.QAction( icon, self.tr('&Open'), actions, objectName='openAction', shortcut=self.tr('Ctrl+O'), statusTip=self.tr('Open'), triggered=self.onOpen) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogSaveButton) QtWidgets.QAction( icon, self.tr('&Save As'), actions, objectName='saveAsAction', shortcut=self.tr('Ctrl+S'), statusTip=self.tr('Save as'), triggered=self.onSave) icon = QtGui.QIcon.fromTheme('printer') QtWidgets.QAction( icon, self.tr('&Print'), actions, objectName='printAction', shortcut=self.tr('Ctrl+P'), statusTip=self.tr('Print'), triggered=self.onPrint) QtWidgets.QAction(actions).setSeparator(True) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCancelButton) QtWidgets.QAction( icon, self.tr('&Quit'), actions, objectName='exitAction', shortcut=self.tr('Ctrl+Q'), statusTip=self.tr('Quit'), triggered=self.close) return actions
def _setupFileActions(self): # @TODO: add a "close all" (items) action actionsgroup = QtWidgets.QActionGroup(self) # Open icon = qtsupport.geticon('open.svg', __name__) QtWidgets.QAction( icon, self.tr('&Open'), actionsgroup, objectName='openAction', shortcut=self.tr('Ctrl+O'), toolTip=self.tr('Open an existing file'), statusTip=self.tr('Open an existing file'), triggered=self.openFile) # Close icon = qtsupport.geticon('close.svg', __name__) QtWidgets.QAction( icon, self.tr('&Close'), actionsgroup, objectName='closeAction', # 'Ctrl+W' shortcut is used for closing windows # shortcut=self.tr('Ctrl+W'), toolTip=self.tr('Close the current file'), statusTip=self.tr('Close the current file'), triggered=self.closeItem) # Separator QtWidgets.QAction(actionsgroup).setSeparator(True) # objectName='separator') # Exit icon = qtsupport.geticon('quit.svg', __name__) QtWidgets.QAction( icon, self.tr('&Exit'), actionsgroup, objectName='exitAction', shortcut=self.tr('Ctrl+X'), toolTip=self.tr('Exit the program'), statusTip=self.tr('Exit the program'), triggered=self.close) return actionsgroup
def _setupBandItemActions(self, actionsgroup=None): if actionsgroup is None: actionsgroup = QtWidgets.QActionGroup(self) # open image view icon = qtsupport.geticon('open.svg', __name__) QtWidgets.QAction( icon, self.tr('&Open Image View'), actionsgroup, objectName='actionOpenImageView', shortcut=self.tr('Ctrl+O'), toolTip=self.tr('Open an image view'), statusTip=self.tr('Open a new image view'), triggered=self.openImageView) # @TODO: add a new action for newImageView # @TODO: Masked bands, Compute statistics, Compute histogram # @TODO: dataset --> Build overviews self._setupMajorObjectItemActions(actionsgroup) return actionsgroup