def __init__(self, parent=None, designMode=False, readWClass=None, writeWClass=None, enterEditTriggers=None, exitEditTriggers=None): TaurusWidget.__init__(self, parent=parent, designMode=designMode) self.setFocusPolicy(Qt.Qt.StrongFocus) self.setLayout(Qt.QStackedLayout()) self.readWidget = None self.writeWidget = None # Use parameters from constructor args or defaults from class self.readWClass = readWClass or self.readWClass self.writeWClass = writeWClass or self.writeWClass self.enterEditTriggers = enterEditTriggers or self.enterEditTriggers self.exitEditTriggers = exitEditTriggers or self.exitEditTriggers # classify the triggers sc, et, sig = self._classifyTriggers(self.enterEditTriggers) self.enterEditShortCuts = sc self.enterEditEventTypes = et self.enterEditSignals = sig sc, et, sig = self._classifyTriggers(self.exitEditTriggers) self.exitEditShortCuts = sc self.exitEditEventTypes = et self.exitEditSignals = sig # Actions for entering and exiting the edit self.enterEditAction = Qt.QAction("Start Editing", self) self.enterEditAction.setShortcuts(self.enterEditShortCuts) self.enterEditAction.setShortcutContext( Qt.Qt.WidgetWithChildrenShortcut) self.addAction(self.enterEditAction) self.exitEditAction = Qt.QAction("Abort Editing", self) self.exitEditAction.setShortcuts(self.exitEditShortCuts) self.exitEditAction.setShortcutContext( Qt.Qt.WidgetWithChildrenShortcut) self.addAction(self.exitEditAction) self.connect(self.enterEditAction, Qt.SIGNAL("triggered()"), self._onEnterEditActionTriggered) self.connect(self.exitEditAction, Qt.SIGNAL("triggered()"), self._onExitEditActionTriggered) # add read and write widgets if self.readWClass is not None: self.setReadWidget(self.readWClass()) if self.writeWClass is not None: self.setWriteWidget(self.writeWClass())
def __init__(self, *args, **kwargs): TaurusWidget.__init__(self, *args) fileModel = kwargs.get('fileModel', None) if fileModel is None: fileModel = HDF5Widget.FileModel() self.__fileModel = fileModel self.treeWidget = HDF5Widget.HDF5Widget(self.__fileModel) self.treeWidget.setSizePolicy(Qt.QSizePolicy( Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Expanding)) # self.infoWidget = HDF5Info.HDF5InfoWidget() self.__previewStack = Qt.QStackedWidget() self.__currentPreview = None # layout self.__splitter = Qt.QSplitter() self.__splitter.setOrientation(Qt.Qt.Vertical) self.__splitter.addWidget(self.treeWidget) # self.__splitter.addWidget(self.infoWidget) self.__splitter.addWidget(self.__previewStack) self.setLayout(Qt.QVBoxLayout()) self.layout().addWidget(self.__splitter) # Actions self.setContextMenuPolicy(Qt.Qt.ActionsContextMenu) self.openFileAction = Qt.QAction(Qt.QIcon.fromTheme("document-open"), "Open Data File...", self) self.togglePreviewAction = Qt.QAction(Qt.QIcon("actions:view.svg"), "Show/Hide preview", self) self.togglePreviewAction.setCheckable(True) self.togglePreviewAction.setChecked(True) self.addActions([self.openFileAction, self.togglePreviewAction]) # Toolbar self._toolbar = Qt.QToolBar("NeXus browser toolbar") self._toolbar.setIconSize(Qt.QSize(16, 16)) self._toolbar.setFloatable(False) self._toolbar.addActions( [self.openFileAction, self.togglePreviewAction]) self.layout().setMenuBar(self._toolbar) # connections self.__fileModel.sigFileAppended.connect(self.treeWidget.fileAppended) self.treeWidget.sigHDF5WidgetSignal.connect(self.onHDF5WidgetSignal) self.openFileAction.triggered.connect( partial(self.openFile, fname=None)) self.togglePreviewAction.toggled.connect(self.__previewStack.setVisible) # configuration self.registerConfigProperty( self.togglePreviewAction.isChecked, self.togglePreviewAction.setChecked, 'showPreview')
def _initActions(self): """Initializes the actions for this widget (currently, the pause action.) """ self._pauseAction = Qt.QAction("&Pause", self) self._pauseAction.setShortcuts([Qt.Qt.Key_P, Qt.Qt.Key_Pause]) self._pauseAction.setCheckable(True) self._pauseAction.setChecked(False) self.addAction(self._pauseAction) self._pauseAction.toggled.connect(self.setPaused) self.chooseModelAction = Qt.QAction("Choose &Model", self) self.chooseModelAction.setEnabled(self.isModifiableByUser()) self.addAction(self.chooseModelAction) self.chooseModelAction.triggered[()].connect(self.chooseModel)
def createAction(self, parent, text, shortcut=None, icon=None, tip=None, toggled=None, triggered=None, data=None, context=Qt.Qt.WindowShortcut): """Create a QAction""" action = Qt.QAction(text, parent) if triggered is not None: action.triggered.connect(triggered) if toggled is not None: action.toggled.connect(toggled) action.setCheckable(True) if icon is not None: if isinstance(icon, (str, unicode)): icon = Qt.QIcon.fromTheme(icon) action.setIcon(icon) if shortcut is not None: action.setShortcut(shortcut) if tip is not None: action.setToolTip(tip) action.setStatusTip(tip) if data is not None: action.setData(data) # TODO: Hard-code all shortcuts and choose context=Qt.WidgetShortcut # (this will avoid calling shortcuts from another dockwidget # since the context thing doesn't work quite well with these widgets) action.setShortcutContext(context) return action
def __init__(self, parent=None): """__init__(self, parent = None) -> QWheelEdit Constructor @param[in] parent (QWidget) the parent widget (optional, default is None meaning there is no parent """ Qt.QFrame.__init__(self, parent) Qt.QGridLayout(self) self._roundFunc = None self._previous_value = 0 self._value = 0 self._value_str = '0' self._minValue = numpy.finfo('d').min # -inf self._maxValue = numpy.finfo('d').max # inf self._editor = None self._editing = False self._hideEditWidget = True self._showArrowButtons = True self._forwardReturn = False self._validator = Qt.QDoubleValidator(self) self._validator.setNotation(self._validator.StandardNotation) self._setDigits(QWheelEdit.DefaultIntDigitCount, QWheelEdit.DefaultDecDigitCount) self._setValue(0) self._build() self.setDigitCountAction = Qt.QAction("Change digits", self) self.setDigitCountAction.triggered.connect(self._onSetDigitCount) self.addAction(self.setDigitCountAction) self.setContextMenuPolicy(Qt.Qt.ActionsContextMenu)
def createConfigureAction(self): configureAction = Qt.QAction(getThemeIcon( "preferences-system-session"), "Change configuration", self) configureAction.triggered.connect(self.changeConfiguration) configureAction.setToolTip("Configuring MacroServer and Door") configureAction.setShortcut("F10") return configureAction
def __init__(self, parent=None, designmode=False): TaurusWidget.__init__(self, parent, designmode) self._modelcommands = [] self._buttons = [] self.setLayout(Qt.QGridLayout()) self.frame = TaurusWidget(self) self.frame.setUseParentModel(True) self.frame.setLayout(Qt.QGridLayout()) self.scrollArea = TaurusScrollArea(self) self.scrollArea.setUseParentModel(True) self.scrollArea.setWidget(self.frame) self.scrollArea.setWidgetResizable(True) self.layout().addWidget(self.scrollArea) # Adding right click edit action self.setContextMenuPolicy(Qt.Qt.ActionsContextMenu) self.chooseCommandsAction = Qt.QAction('Modify commands', self) self.addAction(self.chooseCommandsAction) self.connect(self.chooseCommandsAction, Qt.SIGNAL("triggered()"), self.chooseCommands) self.setModifiableByUser(True) # Make it saveable self.registerConfigProperty(self.commandsToConfig, self.commandsFromConfig, 'commands')
def createCustomMacroEditorPathsAction(self): configureAction = Qt.QAction(getThemeIcon( "folder-open"), "Change custom macro editors paths", self) configureAction.triggered.connect(self.onCustomMacroEditorPaths) configureAction.setToolTip("Change custom macro editors paths") configureAction.setShortcut("F11") return configureAction
def createMenuActions(self): """Returns a list of menu actions and a list of IO actions. Reimplement in derived classes. This Base (dummy) implementation creates empty menu actions and a list of 5 dummy actions for the IO actions """ dummyaction = Qt.QAction(self) return [], [dummyaction]*4
def __init__(self, parent=None, initMacroServer=None, initDoor=None): Qt.QDialog.__init__(self, parent) self.initMacroServer = initMacroServer self.initDoor = initDoor configureAction = Qt.QAction(getThemeIcon( "folder-open"), "Change custom macro editors paths", self) configureAction.triggered.connect(self.onReloadMacroServers) configureAction.setToolTip("Change custom macro editors paths") configureAction.setShortcut("F11") self.refreshMacroServersAction = Qt.QAction( getThemeIcon("view-refresh"), "Reload macroservers", self) self.refreshMacroServersAction.triggered.connect( self.onReloadMacroServers) self.refreshMacroServersAction.setToolTip( "This will reload list of all macroservers from Tango DB") self.refreshMacroServersAction.setShortcut("F5") self.initComponents()
def __init__(self, parent=None): Qt.QPlainTextEdit.__init__(self, parent) self.setReadOnly(True) self.setFont(Qt.QFont("Courier", 9)) self.stopAction = Qt.QAction("Stop scrolling", self) self.stopAction.setCheckable(True) self.stopAction.setChecked(False) self._isStopped = False
def __init__(self, parent=None): Qt.QTreeView.__init__(self, parent) BaseConfigurableClass.__init__(self) self._idIndexDict = {} self.setSelectionBehavior(Qt.QTreeView.SelectRows) self.setSelectionMode(Qt.QTreeView.SingleSelection) self.setRootIsDecorated(False) # self.setItemsExpandable(False) self.setDragEnabled(True) self.setAcceptDrops(True) self.setTabKeyNavigation(True) self.setEditTriggers(Qt.QAbstractItemView.EditKeyPressed | Qt.QAbstractItemView.CurrentChanged) self.setDropIndicatorShown(True) self.deleteAction = Qt.QAction( Qt.QIcon.fromTheme("list-remove"), "Remove macro", self) self.deleteAction.triggered.connect(self.deleteMacro) self.deleteAction.setToolTip( "Clicking this button will remove current macro.") self.moveUpAction = Qt.QAction(Qt.QIcon.fromTheme("go-up"), "Move up", self) self.moveUpAction.triggered.connect(self.upMacro) self.moveUpAction.setToolTip( "Clicking this button will move current macro up.") self.moveDownAction = Qt.QAction( Qt.QIcon.fromTheme("go-down"), "Move down", self) self.moveDownAction.triggered.connect(self.downMacro) self.moveDownAction.setToolTip( "Clicking this button will move current macro down.") self.moveLeftAction = Qt.QAction( Qt.QIcon.fromTheme("go-previous"), "Move left", self) self.moveLeftAction.triggered.connect(self.leftMacro) self.moveLeftAction.setToolTip( "Clicking this button will move current macro to the left.") self.moveRightAction = Qt.QAction( Qt.QIcon.fromTheme("go-next"), "Move right", self) self.moveRightAction.triggered.connect(self.rightMacro) self.moveRightAction.setToolTip( "Clicking this button will move current macro to the right.")
def contextMenuEvent(self, event): menu = self.createStandardContextMenu() clearAction = Qt.QAction("Clear", menu) menu.addAction(clearAction) if not len(self.toPlainText()): clearAction.setEnabled(False) clearAction.triggered.connect(self.clear) menu.exec_(event.globalPos())
def __init__(self, parent=None): Qt.QListView.__init__(self, parent) self.setSelectionMode(Qt.QListView.SingleSelection) self.removeAllAction = Qt.QAction(Qt.QIcon("places:user-trash.svg"), "Remove all from history", self) self.removeAllAction.triggered.connect(self.removeAllMacros) self.removeAllAction.setToolTip( "Clicking this button will remove all macros from history.") self.removeAllAction.setEnabled(False)
def register_kernel_extension(self, extension): f = functools.partial(self.create_tab_with_new_frontend, name=extension.Name, label=extension.Label) action = Qt.QAction(extension.Label, self, triggered=f) if self.new_kernel_menu is None: self._pending_kernel_actions.append(action) else: self.add_new_kernel_action(action)
def __init__(self, parent=None, designMode=False): Qt.QTreeView.__init__(self, parent) self.setSelectionBehavior(Qt.QTreeView.SelectItems) self.setRootIsDecorated(False) # self.setTabKeyNavigation(True) self.setEditTriggers(Qt.QAbstractItemView.AllEditTriggers) self.addAction = Qt.QAction(getThemeIcon("list-add"), "Add new repetition", self) self.connect(self.addAction, Qt.SIGNAL("triggered()"), self.onAddRepeat) self.addAction.setToolTip( "Clicking this button will add new repetition to current parameter." ) self.deleteAction = Qt.QAction(getThemeIcon("list-remove"), "Remove repetition", self) self.connect(self.deleteAction, Qt.SIGNAL("triggered()"), self.onDelRepeat) self.deleteAction.setToolTip( "Clicking this button will remove current repetition.") self.moveUpAction = Qt.QAction(getThemeIcon("go-up"), "Move up", self) self.connect(self.moveUpAction, Qt.SIGNAL("triggered()"), self.onUpRepeat) self.moveUpAction.setToolTip( "Clicking this button will move current repetition up.") self.moveDownAction = Qt.QAction(getThemeIcon("go-down"), "Move down", self) self.connect(self.moveDownAction, Qt.SIGNAL("triggered()"), self.onDownRepeat) self.moveDownAction.setToolTip( "Clicking this button will move current repetition down.") self.duplicateAction = Qt.QAction(getThemeIcon("edit-copy"), "Duplicate", self) self.connect(self.duplicateAction, Qt.SIGNAL("triggered()"), self.onDuplicateRepeat) msg = "Clicking this button will duplicate the given node." self.duplicateAction.setToolTip(msg) self.disableActions()
def __init__(self, parent=None, designMode=False, with_filter_widget=True, perspective=None): TaurusBaseTableWidget.__init__(self, parent=parent, designMode=designMode, with_filter_widget=with_filter_widget, perspective=perspective, proxy=None) self.setContextMenuPolicy(Qt.Qt.ActionsContextMenu) self._simpleViewAction = Qt.QAction("Simple View", self) self._simpleViewAction.setCheckable(True) self._simpleViewAction.toggled.connect(self.setSimpleView) self.addAction(self._simpleViewAction) self.registerConfigProperty( self.isSimpleView, self.setSimpleView, "simpleView")
def contextMenuEvent(self, event): menu = self.createStandardContextMenu() clearAction = Qt.QAction("Clear", menu) menu.addAction(clearAction) menu.addAction(self.stopAction) if not len(self.toPlainText()): clearAction.setEnabled(False) Qt.QObject.connect(clearAction, Qt.SIGNAL("triggered()"), self.clear) Qt.QObject.connect(self.stopAction, Qt.SIGNAL("toggled(bool)"), self.stopScrolling) menu.exec_(event.globalPos())
def attachToPlotItem(self, plot_item): """ Use this method to add this tool to a plot :param plot_item: (PlotItem) """ self._plot_item = plot_item view = plot_item.getViewBox() menu = view.menu model_chooser = Qt.QAction("Model selection", menu) model_chooser.triggered.connect(self._onTriggered) menu.addAction(model_chooser)
def contextMenuEvent(self, event): menu = self.createStandardContextMenu() clearAction = Qt.QAction("Clear", menu) menu.addAction(clearAction) menu.addAction(self.stopAction) menu.addAction(self.showDebug) if not len(self.toPlainText()): clearAction.setEnabled(False) clearAction.triggered.connect(self.clear) self.stopAction.toggled.connect(self.stopScrolling) self.showDebug.toggled.connect(self.showDebugDetails) menu.exec_(event.globalPos())
def __init__(self, parent=None): Qt.QPlainTextEdit.__init__(self, parent) self.setReadOnly(True) self.setFont(Qt.QFont("Courier", 9)) self.stopAction = Qt.QAction("Stop scrolling", self) self.stopAction.setCheckable(True) self.stopAction.setChecked(False) self._isStopped = False from taurus.core.util.log import warning msg = ("DoorDebug is deprecated since version 3.0.3. " "Use DoorOutput 'Show debug details' feature instead.") warning(msg)
def __init__(self, parent): Qt.QListView.__init__(self, parent) self.setSelectionMode(Qt.QListView.ExtendedSelection) self.removeAction = Qt.QAction(getIcon(":/actions/list-remove.svg"), "Remove from favourites", self) self.connect(self.removeAction, Qt.SIGNAL("triggered()"), self.removeMacros) self.removeAction.setToolTip( "Clicking this button will remove selected macros " "from favourites.") self.removeAllAction = Qt.QAction(getIcon(":/places/user-trash.svg"), "Remove all from favourites", self) self.connect(self.removeAllAction, Qt.SIGNAL( "triggered()"), self.removeAllMacros) self.removeAllAction.setToolTip( "Clicking this button will remove all macros from favourites.") self.moveUpAction = Qt.QAction(getIcon(":/actions/go-up.svg"), "Move up", self) self.connect(self.moveUpAction, Qt.SIGNAL( "triggered()"), self.upMacro) self.moveUpAction.setToolTip( "Clicking this button will move the macro up " "in the favourites hierarchy.") self.moveDownAction = Qt.QAction(getIcon(":/actions/go-down.svg"), "Move down", self) self.connect(self.moveDownAction, Qt.SIGNAL( "triggered()"), self.downMacro) self.moveDownAction.setToolTip( "Clicking this button will move the macro down " "in the favourites hierarchy.") self.disableActions()
def __init__(self, parent=None, door=None, plotsButton=True): Qt.QWidget.__init__(self, parent) TaurusBaseWidget.__init__(self, 'ExpDescriptionEditor') self.loadUi() self.ui.buttonBox.setStandardButtons(Qt.QDialogButtonBox.Reset | Qt.QDialogButtonBox.Apply) newperspectivesDict = copy.deepcopy(self.ui.sardanaElementTree.KnownPerspectives) #newperspectivesDict[self.ui.sardanaElementTree.DftPerspective]['model'] = [SardanaAcquirableProxyModel, SardanaElementPlainModel] newperspectivesDict[self.ui.sardanaElementTree.DftPerspective]['model'][0] = SardanaAcquirableProxyModel self.ui.sardanaElementTree.KnownPerspectives = newperspectivesDict #assign a copy because if just a key of this class memberwas modified, all instances of this class would be affected self.ui.sardanaElementTree._setPerspective(self.ui.sardanaElementTree.DftPerspective) self._localConfig = None self._originalConfiguration = None self._dirty = False self._dirtyMntGrps = set() self.connect(self.ui.activeMntGrpCB, Qt.SIGNAL('activated (QString)'), self.changeActiveMntGrp) self.connect(self.ui.createMntGrpBT, Qt.SIGNAL('clicked ()'), self.createMntGrp) self.connect(self.ui.deleteMntGrpBT, Qt.SIGNAL('clicked ()'), self.deleteMntGrp) self.connect(self.ui.compressionCB, Qt.SIGNAL('currentIndexChanged (int)'), self.onCompressionCBChanged) self.connect(self.ui.pathLE, Qt.SIGNAL('textEdited (QString)'), self.onPathLEEdited) self.connect(self.ui.filenameLE, Qt.SIGNAL('textEdited (QString)'), self.onFilenameLEEdited) self.connect(self.ui.channelEditor.getQModel(), Qt.SIGNAL('dataChanged (QModelIndex, QModelIndex)'), self._updateButtonBox) self.connect(self.ui.channelEditor.getQModel(), Qt.SIGNAL('modelReset ()'), self._updateButtonBox) preScanList = self.ui.preScanList self.connect(preScanList, Qt.SIGNAL('dataChanged'), self.onPreScanSnapshotChanged) #TODO: For Taurus 4 compatibility if hasattr(preScanList, "dataChangedSignal"): preScanList.dataChangedSignal.connect(self.onPreScanSnapshotChanged) self.connect(self.ui.choosePathBT, Qt.SIGNAL('clicked ()'), self.onChooseScanDirButtonClicked) self.__plotManager = None icon = resource.getIcon(":/actions/view.svg") self.togglePlotsAction = Qt.QAction(icon, "Show/Hide plots", self) self.togglePlotsAction.setCheckable(True) self.togglePlotsAction.setChecked(False) self.togglePlotsAction.setEnabled(plotsButton) self.addAction(self.togglePlotsAction) self.connect(self.togglePlotsAction, Qt.SIGNAL("toggled(bool)"), self.onPlotsButtonToggled) self.ui.plotsButton.setDefaultAction(self.togglePlotsAction) if door is not None: self.setModel(door) self.connect(self.ui.buttonBox, Qt.SIGNAL("clicked(QAbstractButton *)"), self.onDialogButtonClicked) #Taurus Configuration properties and delegates self.registerConfigDelegate(self.ui.channelEditor)
def contextMenuEvent(self, event): # Overwrite the default taurus label behaviour menu = Qt.QMenu(self) action_tango_attributes = Qt.QAction(self) action_tango_attributes.setIcon( getIcon(":/categories/preferences-system.svg")) action_tango_attributes.setText("Tango Attributes") menu.addAction(action_tango_attributes) action_tango_attributes.triggered.connect( self.taurusValueBuddy().showTangoAttributes) cm_action = menu.addAction("Compact") cm_action.setCheckable(True) cm_action.setChecked(self.taurusValueBuddy().isCompact()) cm_action.toggled.connect(self.taurusValueBuddy().setCompact) menu.exec_(event.globalPos()) event.accept()
def createAction(self, text="", slot=None, shortcut=None, icon=None, tip=None, checkable=False, signal="triggered()"): action = Qt.QAction(text, self) if icon is not None: action.setIcon(Qt.QIcon(icon)) if shortcut is not None: action.setShortcut(shortcut) if tip is not None: action.setToolTip(tip) action.setStatusTip(tip) if slot is not None: Qt.QObject.connect(action, Qt.SIGNAL(signal), slot) if checkable: action.setCheckable(True) return action
def __init__(self, parent=None, designMode=False): TaurusWidget.__init__(self, parent, designMode) # list representing all macros ids (all from sequence) currently # executed self._macroIds = [] self._sequencesPath = str(Qt.QDir.homePath()) self._sequenceModel = MacroSequenceTreeModel() self.registerConfigProperty("sequencesPath", "setSequencesPath", "sequencesPath") self.setLayout(Qt.QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) splitter = Qt.QSplitter() self.layout().addWidget(splitter) splitter.setOrientation(Qt.Qt.Vertical) sequenceEditor = TaurusWidget() splitter.addWidget(sequenceEditor) sequenceEditor.setUseParentModel(True) sequenceEditor.setLayout(Qt.QVBoxLayout()) sequenceEditor.layout().setContentsMargins(0, 0, 0, 0) self.tree = MacroSequenceTree(sequenceEditor) self.sequenceProxyModel = MacroSequenceProxyModel() self.sequenceProxyModel.setSourceModel(self._sequenceModel) self.tree.setModel(self.sequenceProxyModel) self.tree.setItemDelegate(SequenceEditorDelegate(self.tree)) actionsLayout = Qt.QHBoxLayout() actionsLayout.setContentsMargins(0, 0, 0, 0) self.newSequenceAction = Qt.QAction(getThemeIcon("document-new"), "New", self) self.newSequenceAction.triggered.connect(self.onNewSequence) self.newSequenceAction.setToolTip("New sequence") self.newSequenceAction.setEnabled(False) newSequenceButton = Qt.QToolButton() newSequenceButton.setDefaultAction(self.newSequenceAction) actionsLayout.addWidget(newSequenceButton) self.openSequenceAction = Qt.QAction(getThemeIcon("document-open"), "Open...", self) self.openSequenceAction.triggered.connect(self.onOpenSequence) self.openSequenceAction.setToolTip("Open sequence...") openSequenceButton = Qt.QToolButton() openSequenceButton.setDefaultAction(self.openSequenceAction) actionsLayout.addWidget(openSequenceButton) self.saveSequenceAction = Qt.QAction(getThemeIcon("document-save"), "Save...", self) self.saveSequenceAction.triggered.connect(self.onSaveSequence) self.saveSequenceAction.setToolTip("Save sequence...") self.saveSequenceAction.setEnabled(False) saveSequenceButton = Qt.QToolButton() saveSequenceButton.setDefaultAction(self.saveSequenceAction) actionsLayout.addWidget(saveSequenceButton) self.stopSequenceAction = Qt.QAction( getIcon(":/actions/media_playback_stop.svg"), "Stop", self) self.stopSequenceAction.triggered.connect(self.onStopSequence) self.stopSequenceAction.setToolTip("Stop sequence") stopSequenceButton = Qt.QToolButton() stopSequenceButton.setDefaultAction(self.stopSequenceAction) actionsLayout.addWidget(stopSequenceButton) self.pauseSequenceAction = Qt.QAction( getIcon(":/actions/media_playback_pause.svg"), "Pause", self) self.pauseSequenceAction.triggered.connect(self.onPauseSequence) self.pauseSequenceAction.setToolTip("Pause sequence") pauseSequenceButton = Qt.QToolButton() pauseSequenceButton.setDefaultAction(self.pauseSequenceAction) actionsLayout.addWidget(pauseSequenceButton) self.playSequenceAction = Qt.QAction( getIcon(":/actions/media_playback_start.svg"), "Play", self) self.playSequenceAction.triggered.connect(self.onPlaySequence) self.playSequenceAction.setToolTip("Play sequence") playSequenceButton = Qt.QToolButton() playSequenceButton.setDefaultAction(self.playSequenceAction) actionsLayout.addWidget(playSequenceButton) self.doorStateLed = TaurusLed(self) actionsLayout.addWidget(self.doorStateLed) #@todo this feature will be replaced by checkboxes in the # sequence tree view indicating clearing of the plot after execution self.fullSequencePlotCheckBox = Qt.QCheckBox("Full sequence plot", self) self.fullSequencePlotCheckBox.toggled.connect(self.setFullSequencePlot) self.fullSequencePlotCheckBox.setChecked(True) actionsLayout.addWidget(self.fullSequencePlotCheckBox) spacerItem = Qt.QSpacerItem(0, 0, Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Fixed) actionsLayout.addItem(spacerItem) sequenceEditor.layout().addLayout(actionsLayout) macroLayout = Qt.QHBoxLayout() macroLayout.setContentsMargins(0, 0, 0, 0) macroLabel = Qt.QLabel("Macro:") macroLayout.addWidget(macroLabel) self.macroComboBox = MacroComboBox(self) self.macroComboBox.setUseParentModel(True) self.macroComboBox.setModelColumn(0) self.macroComboBox.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Minimum) macroLayout.addWidget(self.macroComboBox) self.addMacroAction = Qt.QAction(getThemeIcon("list-add"), "Add macro...", self) self.addMacroAction.triggered.connect(self.onAdd) self.addMacroAction.setToolTip( "Clicking this button will add selected macro") self.addMacroAction.setEnabled(False) addButton = Qt.QToolButton() addButton.setDefaultAction(self.addMacroAction) macroLayout.addWidget(addButton) sequenceEditor.layout().addLayout(macroLayout) sequenceLayout = Qt.QHBoxLayout() sequenceLayout.addWidget(self.tree) layout = Qt.QVBoxLayout() delButton = Qt.QToolButton() delButton.setDefaultAction(self.tree.deleteAction) delButton.setEnabled(False) layout.addWidget(delButton) upButton = Qt.QToolButton() upButton.setDefaultAction(self.tree.moveUpAction) upButton.setEnabled(False) layout.addWidget(upButton) downButton = Qt.QToolButton() downButton.setDefaultAction(self.tree.moveDownAction) downButton.setEnabled(False) layout.addWidget(downButton) leftButton = Qt.QToolButton() leftButton.setDefaultAction(self.tree.moveLeftAction) leftButton.setEnabled(False) layout.addWidget(leftButton) rightButton = Qt.QToolButton() rightButton.setDefaultAction(self.tree.moveRightAction) rightButton.setEnabled(False) layout.addWidget(rightButton) spacerItem = Qt.QSpacerItem(0, 40, Qt.QSizePolicy.Fixed, Qt.QSizePolicy.Expanding) layout.addItem(spacerItem) sequenceLayout.addLayout(layout) sequenceEditor.layout().addLayout(sequenceLayout) self.parametersProxyModel = MacroParametersProxyModel() self.parametersProxyModel.setSourceModel(self._sequenceModel) self.stackedWidget = Qt.QStackedWidget() splitter.addWidget(self.stackedWidget) self.standardMacroParametersEditor = StandardMacroParametersEditor( self.stackedWidget) self.standardMacroParametersEditor.setModel(self.parametersProxyModel) self.standardMacroParametersEditor.tree.setItemDelegate( ParamEditorDelegate(self.standardMacroParametersEditor.tree)) self.stackedWidget.addWidget(self.standardMacroParametersEditor) self.customMacroParametersEditor = None self.macroComboBox.currentIndexChanged.connect( self.onMacroComboBoxChanged) self.tree.macroChanged.connect(self.setMacroParametersRootIndex)
def add_new_tango_action(self): tango_action = Qt.QAction("Tango", self, triggered=self.create_tab_with_new_tango_frontend) self.add_new_kernel_action(tango_action)
def __init__(self, parent=None, designMode=False): TaurusWidget.__init__(self, parent, designMode) self.setObjectName(self.__class__.__name__) self._doorName = "" self._macroId = None self.setLayout(Qt.QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.addToFavouritesAction = Qt.QAction( getThemeIcon("software-update-available"), "Add to favourites", self) self.connect(self.addToFavouritesAction, Qt.SIGNAL("triggered()"), self.onAddToFavourites) self.addToFavouritesAction.setToolTip("Add to favourites") self.stopMacroAction = Qt.QAction( getIcon(":/actions/media_playback_stop.svg"), "Stop macro", self) self.connect(self.stopMacroAction, Qt.SIGNAL("triggered()"), self.onStopMacro) self.stopMacroAction.setToolTip("Stop macro") self.pauseMacroAction = Qt.QAction( getIcon(":/actions/media_playback_pause.svg"), "Pause macro", self) self.connect(self.pauseMacroAction, Qt.SIGNAL("triggered()"), self.onPauseMacro) self.pauseMacroAction.setToolTip("Pause macro") self.playMacroAction = Qt.QAction( getIcon(":/actions/media_playback_start.svg"), "Start macro", self) self.connect(self.playMacroAction, Qt.SIGNAL("triggered()"), self.onPlayMacro) self.playMacroAction.setToolTip("Start macro") actionsLayout = Qt.QHBoxLayout() actionsLayout.setContentsMargins(0, 0, 0, 0) addToFavouritsButton = Qt.QToolButton() addToFavouritsButton.setDefaultAction(self.addToFavouritesAction) self.addToFavouritesAction.setEnabled(False) actionsLayout.addWidget(addToFavouritsButton) self.macroComboBox = MacroComboBox(self) self.macroComboBox.setUseParentModel(True) self.macroComboBox.setModelColumn(0) actionsLayout.addWidget(self.macroComboBox) stopMacroButton = Qt.QToolButton() stopMacroButton.setDefaultAction(self.stopMacroAction) actionsLayout.addWidget(stopMacroButton) pauseMacroButton = Qt.QToolButton() pauseMacroButton.setDefaultAction(self.pauseMacroAction) actionsLayout.addWidget(pauseMacroButton) self.playMacroButton = Qt.QToolButton() self.playMacroButton.setDefaultAction(self.playMacroAction) actionsLayout.addWidget(self.playMacroButton) self.disableControlActions() self.doorStateLed = TaurusLed(self) actionsLayout.addWidget(self.doorStateLed) self.layout().addLayout(actionsLayout) splitter = Qt.QSplitter(self) self.layout().addWidget(splitter) splitter.setOrientation(Qt.Qt.Vertical) self._paramEditorModel = ParamEditorModel() self.stackedWidget = Qt.QStackedWidget() self.standardMacroParametersEditor = StandardMacroParametersEditor( self.stackedWidget) self.stackedWidget.addWidget(self.standardMacroParametersEditor) self.customMacroParametersEditor = None splitter.addWidget(self.stackedWidget) self._favouritesBuffer = None self.favouritesMacrosEditor = FavouritesMacrosEditor(self) self.registerConfigDelegate(self.favouritesMacrosEditor) self.favouritesMacrosEditor.setUseParentModel(True) self.favouritesMacrosEditor.setFocusPolicy(Qt.Qt.NoFocus) self._historyBuffer = None self.historyMacrosViewer = HistoryMacrosViewer(self) self.registerConfigDelegate(self.historyMacrosViewer) self.historyMacrosViewer.setUseParentModel(True) self.historyMacrosViewer.setFocusPolicy(Qt.Qt.NoFocus) self.tabMacroListsWidget = Qt.QTabWidget(self) self.tabMacroListsWidget.addTab(self.favouritesMacrosEditor, "Favourite list") self.tabMacroListsWidget.addTab(self.historyMacrosViewer, "History Viewer") splitter.addWidget(self.tabMacroListsWidget) self._isHistoryMacro = False self.macroProgressBar = MacroProgressBar(self) self.layout().addWidget(self.macroProgressBar) #spockCommandLabel = Qt.QLabel("Spock command:", self) #spockCommandLabel.setFont(Qt.QFont("Courier",9)) self.spockCommand = SpockCommandWidget("Spock", self) self.spockCommand.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Minimum) self.spockCommand.setUseParentModel(True) spockCommandLayout = Qt.QHBoxLayout() spockCommandLayout.setContentsMargins(0, 0, 0, 0) #spockCommandLayout.addWidget(spockCommandLabel) spockCommandLayout.addWidget(self.spockCommand) self.layout().addLayout(spockCommandLayout) self.connect(self.macroComboBox, Qt.SIGNAL("currentIndexChanged(QString)"), self.onMacroComboBoxChanged) self.connect(self.favouritesMacrosEditor.list, Qt.SIGNAL("favouriteSelected"), self.onFavouriteSelected) self.connect(self.historyMacrosViewer.list, Qt.SIGNAL("historySelected"), self.onHistorySelected) self.connect(self.spockCommand, Qt.SIGNAL("pressedReturn"), self.onPlayMacro) self.connect(self.spockCommand, Qt.SIGNAL("spockComboBox"), self.setComboBoxItem) self.connect(self.spockCommand, Qt.SIGNAL("elementUp"), self.setHistoryUp) self.connect(self.spockCommand, Qt.SIGNAL("elementDown"), self.setHistoryDown) self.connect(self.spockCommand, Qt.SIGNAL("setHistoryFocus"), self.setHistoryFocus) self.connect(self.spockCommand, Qt.SIGNAL("expandTree"), self.standardMacroParametersEditor.tree.expandAll)
def taurusFormMain(): '''A launcher for TaurusForm.''' # NOTE: DON'T PUT TEST CODE HERE. # THIS IS CALLED FROM THE LAUNCHER SCRIPT (<taurus>/scripts/taurusform) # USE test1() instead. from taurus.qt.qtgui.application import TaurusApplication from taurus.core.util import argparse import sys import os parser = argparse.get_taurus_parser() parser.set_usage("%prog [options] [model1 [model2 ...]]") parser.set_description("the taurus form panel application") parser.add_option("--window-name", dest="window_name", default="TaurusForm", help="Name of the window") parser.add_option("--config", "--config-file", dest="config_file", default=None, help="use the given config file for initialization") app = TaurusApplication(cmd_line_parser=parser, app_name="taurusform", app_version=taurus.Release.version) args = app.get_command_line_args() options = app.get_command_line_options() dialog = TaurusForm() dialog.setModifiableByUser(True) dialog.setModelInConfig(True) dialog.setWindowTitle(options.window_name) # Make sure the window size and position are restored dialog.registerConfigProperty(dialog.saveGeometry, dialog.restoreGeometry, 'MainWindowGeometry') quitApplicationAction = Qt.QAction( Qt.QIcon.fromTheme("process-stop"), 'Close Form', dialog) quitApplicationAction.triggered.connect(dialog.close) saveConfigAction = Qt.QAction("Save current settings...", dialog) saveConfigAction.setShortcut(Qt.QKeySequence.Save) saveConfigAction.triggered.connect( partial(dialog.saveConfigFile, ofile=None)) loadConfigAction = Qt.QAction("&Retrieve saved settings...", dialog) loadConfigAction.setShortcut(Qt.QKeySequence.Open) loadConfigAction.triggered.connect( partial(dialog.loadConfigFile, ifile=None)) dialog.addActions( (saveConfigAction, loadConfigAction, quitApplicationAction)) # set the default map for this installation from taurus import tauruscustomsettings dialog.setCustomWidgetMap( getattr(tauruscustomsettings, 'T_FORM_CUSTOM_WIDGET_MAP', {})) # set a model list from the command line or launch the chooser if options.config_file is not None: dialog.loadConfigFile(options.config_file) elif len(args) > 0: models = args dialog.setModel(models) else: dialog.chooseModels() dialog.show() sys.exit(app.exec_())
def __init__(self, parent=None, formWidget=None, buttons=None, withButtons=True, designMode=False): self._children = [] TaurusWidget.__init__(self, parent, designMode) if buttons is None: buttons = Qt.QDialogButtonBox.Apply | \ Qt.QDialogButtonBox.Reset self._customWidgetMap = {} self._model = [] # self._children = [] self.setFormWidget(formWidget) self.setLayout(Qt.QVBoxLayout()) frame = TaurusWidget() frame.setLayout(Qt.QGridLayout()) self.scrollArea = TaurusScrollArea(self) self.scrollArea.setWidget(frame) self.scrollArea.setWidgetResizable(True) self.layout().addWidget(self.scrollArea) self.__modelChooserDlg = None self.buttonBox = QButtonBox(buttons=buttons, parent=self) self.layout().addWidget(self.buttonBox) self._connectButtons() # Actions (they automatically populate the context menu) self.setContextMenuPolicy(Qt.Qt.ActionsContextMenu) self.chooseModelsAction = Qt.QAction('Modify Contents', self) self.addAction(self.chooseModelsAction) self.chooseModelsAction.triggered.connect(self.chooseModels) self.showButtonsAction = Qt.QAction('Show Buttons', self) self.showButtonsAction.setCheckable(True) self.addAction(self.showButtonsAction) self.showButtonsAction.triggered[bool].connect(self.setWithButtons) self.setWithButtons(withButtons) self.changeLabelsAction = Qt.QAction('Change labels (all items)', self) self.addAction(self.changeLabelsAction) self.changeLabelsAction.triggered.connect(self.onChangeLabelsAction) self.compactModeAction = Qt.QAction('Compact mode (all items)', self) self.compactModeAction.setCheckable(True) self.addAction(self.compactModeAction) self.compactModeAction.triggered[bool].connect(self.setCompact) self.setFormatterAction = Qt.QAction('Set formatter (all items)', self) self.addAction(self.setFormatterAction) self.setFormatterAction.triggered.connect(self.onSetFormatter) self.resetModifiableByUser() self.setSupportedMimeTypes([TAURUS_MODEL_LIST_MIME_TYPE, TAURUS_DEV_MIME_TYPE, TAURUS_ATTR_MIME_TYPE, TAURUS_MODEL_MIME_TYPE, 'text/plain']) self.resetCompact() # properties self.registerConfigProperty( self.isWithButtons, self.setWithButtons, 'withButtons') self.registerConfigProperty(self.isCompact, self.setCompact, 'compact')