def __init__(self, view=None, parent=None, designMode=False): BaseToolBar.__init__(self, name="Taurus selection toolbar", view=view, parent=parent, designMode=designMode) af = ActionFactory() self._goIntoAction = af.createAction(self, "Go Into", icon=getThemeIcon("go-down"), tip="Go into the selected item", triggered=self.goInto) self._goUpAction = af.createAction(self, "Go Up", icon=getThemeIcon("go-up"), tip="Go up one level", triggered=self.goUp) self._goTopAction = af.createAction(self, "Go Top", icon=getThemeIcon("go-top"), tip="Go to top level", triggered=self.goTop) self.addAction(self._goIntoAction) self.addAction(self._goUpAction) self.addAction(self._goTopAction) self._navigationWidget = _NavigationWidget(view, self, parent=self) self._navigationAction = self.addWidget(self._navigationWidget)
def __init__(self,parent=None): QtGui.QWidget.__init__(self,parent) self.gridLayout = QtGui.QGridLayout(self) self.gridLayout.setObjectName("gridLayout") self.comboBox = QtGui.QComboBox(self) self.comboBox.setObjectName("comboBox") self.comboBox.addItem(QtCore.QString("")) self.comboBox.addItem(QtCore.QString("(")) self.comboBox.addItem(QtCore.QString(")")) self.comboBox.addItem(QtCore.QString("OR")) self.comboBox.addItem(QtCore.QString("AND")) self.comboBox.addItem(QtCore.QString("XOR")) self.comboBox.addItem(QtCore.QString("NOT")) self.gridLayout.addWidget(self.comboBox, 0, 0, 1, 1) self.pushButton = QtGui.QPushButton(self) self.pushButton.setObjectName("pushButton") self.pushButton.setIcon(getThemeIcon("go-up")) self.gridLayout.addWidget(self.pushButton, 0, 2, 1, 1) self.pushButton_2 = QtGui.QPushButton(self) self.pushButton_2.setObjectName("pushButton_2") self.pushButton_2.setIcon(getThemeIcon("go-down")) self.gridLayout.addWidget(self.pushButton_2, 0, 3, 1, 1) self.pushButton_3 = QtGui.QPushButton(self) self.pushButton_3.setObjectName("pushButton_3") self.pushButton_3.setIcon(getThemeIcon("list-remove")) self.gridLayout.addWidget(self.pushButton_3, 0, 5, 1, 1) self.spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.gridLayout.addItem(self.spacerItem, 0, 1, 1, 1) self.spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.gridLayout.addItem(self.spacerItem1, 0, 4, 1, 1) QtCore.QObject.connect(self.comboBox, QtCore.SIGNAL("currentIndexChanged(QString)"), self.CreateText)
def processSrc(self, src): '''processes the src and sets the values of display, icon and ok attributes''' if src is None: self.display, self.icon, self.ok = '(Use indices)', Qt.QIcon( ), True return src = str(src).strip() # empty if src == '': self.display, self.icon, self.ok = '(Use indices)', Qt.QIcon( ), True return # for formulas if src.startswith('='): #@todo: evaluate/validate the expression self.display, self.icon, self.ok = src[1:].strip(), getThemeIcon( 'accessories-calculator'), True return # for tango attributes try: attr = taurus.Attribute(src) dev = attr.getParentObj() except TaurusException: self.display, self.icon, self.ok = src, getThemeIcon( 'dialog-warning'), False return if not dev.isValidDev(): self.display, self.icon, self.ok = src, getThemeIcon( 'network-error'), False return self.display, self.icon, self.ok = attr.getSimpleName(), getIcon( ':/taurus.png'), True
def __init__(self, parent=None, paramModel=None): ParamBase.__init__(self, paramModel) Qt.QWidget.__init__(self, parent) self.setLayout(Qt.QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) addNewColumnButton = Qt.QPushButton(getThemeIcon("list-add"), "Add new column...", self) removeSelectedColumnsButton = Qt.QPushButton( getThemeIcon("list-remove"), "Remove selected...", self) buttonsLayout = Qt.QHBoxLayout() buttonsLayout.addWidget(addNewColumnButton) buttonsLayout.addWidget(removeSelectedColumnsButton) self.layout().addLayout(buttonsLayout) self.extraColumnsTable = ExtraColumnsTable(self) self.extraColumnsModel = ExtraColumnsModel() self.extraColumnsTable.setModel(self.extraColumnsModel) self.extraColumnsTable.setItemDelegate( ExtraColumnsDelegate(self.extraColumnsTable)) self.layout().addWidget(self.extraColumnsTable) addNewColumnButton.clicked.connect(self.onAddNewColumn) removeSelectedColumnsButton.clicked.connect( self.onRemoveSelectedColumns) self.extraColumnsModel.dataChanged.connect(self.onExtraColumnsChanged) self.extraColumnsModel.modelReset.connect(self.onExtraColumnsChanged)
def initStyle(self,show=False): print 'In AlarmFormula.initStyle(%s)' %(self.obj or self.formula) try: self.org_formula = self.formula self.setChildrenCollapsible(False) self.setOrientation(Qt.Qt.Vertical) ################################################################### upperPanel = Qt.QFrame() #self upperPanel.setLayout(Qt.QGridLayout()) self.insertWidget(0,upperPanel) self.editcb = Qt.QCheckBox('Edit') self.undobt = Qt.QPushButton() self.savebt = Qt.QPushButton() l = Qt.QLabel('Formula:') l.setFont(get_bold_font()) self.tf = fandango.qt.QDropTextEdit() #Qt.QTextBrowser() self.tf.setMinimumHeight(100) if self.obj is not None: self.tf.setClickHook(self.onEdit)#@todo setClickHook stop working for unknown reasons !?!?! self.tf.setReadOnly(True) self.tf.setEnabled(False) self.connect(self.editcb,Qt.SIGNAL('toggled(bool)'),self.onEdit) upperPanel.layout().addWidget(self.editcb,0,4,1,1) self.undobt.setIcon(resource.getThemeIcon('edit-undo')) self.undobt.setToolTip('Undo changes in formula') self.undobt.setEnabled(True) self.connect(self.undobt,Qt.SIGNAL('pressed()'),self.undoEdit) upperPanel.layout().addWidget(self.undobt,0,5,1,1) self.savebt.setIcon(resource.getThemeIcon('media-floppy')) self.savebt.setToolTip('Save Alarm Formula') self.savebt.setEnabled(False) upperPanel.layout().addWidget(self.savebt,0,6,1,1) self.connect(self.savebt,Qt.SIGNAL('pressed()'),self.onSave) upperPanel.layout().addWidget(l,0,0,1,1) upperPanel.layout().addWidget(self.tf,1,0,1,7) ################################################################### lowerPanel,row = Qt.QFrame(),0 #self,2 lowerPanel.setLayout(Qt.QGridLayout()) self.insertWidget(1,lowerPanel) l = Qt.QLabel('Result:') l.setFont(get_bold_font()) lowerPanel.layout().addWidget(l,row,0,1,1) self.tb = Qt.QTextEdit() #tb.setPlainText('Formula:\n\t%s\n\nOutput:\n\t%s'%(test.source,result)) self.tb.setMinimumHeight(50) self.tb.setReadOnly(True) self.redobt = Qt.QPushButton() self.redobt.setIcon(resource.getThemeIcon('view-refresh')) self.redobt.setToolTip('Update result') self.connect(self.redobt,Qt.SIGNAL('pressed()'),self.updateResult) lowerPanel.layout().addWidget(self.redobt,row,6,1,1) lowerPanel.layout().addWidget(self.tb,row+1,0,1,7) ################################################################### #Refresh from formula: if self.formula: self.updateFormula(self.formula) if show: self.show() print 'AlarmFormula.initStyle(%s) finished.'%self.formula except: print traceback.format_exc() print 'Unable to show AlarmFormula(%s)'%self.formula
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) self.connect(configureAction, Qt.SIGNAL("triggered()"), self.onReloadMacroServers) configureAction.setToolTip("Change custom macro editors paths") configureAction.setShortcut("F11") self.refreshMacroServersAction = Qt.QAction(getThemeIcon("view-refresh"), "Reload macroservers", self) self.connect(self.refreshMacroServersAction, Qt.SIGNAL("triggered()"), self.onReloadMacroServers) self.refreshMacroServersAction.setToolTip("This will reload list of all macroservers from Tango DB") self.refreshMacroServersAction.setShortcut("F5") self.initComponents()
def retranslateUi(self, Form): Form.setWindowTitle(QtGui.QApplication.translate("Form", "Alarm History Viewer", None, QtGui.QApplication.UnicodeUTF8)) self.refreshButton.setText(QtGui.QApplication.translate("Form", "Refresh", None, QtGui.QApplication.UnicodeUTF8)) self.refreshButton.setIcon(getThemeIcon("view-refresh")) self.refreshButton.setToolTip("Refresh list") self.viewButton.setText(QtGui.QApplication.translate("Form", "Open Snapshot", None, QtGui.QApplication.UnicodeUTF8)) self.viewButton.setIcon(getThemeIcon("face-glasses")) self.viewButton.setToolTip("Open Snapshot") QtCore.QObject.connect(self.alarmCombo, QtCore.SIGNAL("currentIndexChanged(QString)"), self.buildList) QtCore.QObject.connect(self.refreshButton, QtCore.SIGNAL("clicked()"), self.onRefresh) QtCore.QObject.connect(self.viewButton, QtCore.SIGNAL("clicked()"), self.onOpen) QtCore.QObject.connect(self.tableWidget, QtCore.SIGNAL("itemDoubleClicked(QTableWidgetItem *)"), self.onDouble) QtCore.QObject.connect(self.tableWidget, QtCore.SIGNAL("customContextMenuRequested(const QPoint&)"), self.onContextMenu)
def addRetranslateUi(self, addForm): addForm.setWindowTitle(QtGui.QApplication.translate("addForm", "Add Recipient", None, QtGui.QApplication.UnicodeUTF8)) self.addButton.setText(QtGui.QApplication.translate("addForm", "Add", None, QtGui.QApplication.UnicodeUTF8)) self.addButton.setIcon(getThemeIcon("list-add")) self.addButton.setToolTip("Add person to the list") self.cancelButton.setText(QtGui.QApplication.translate("addForm", "Cancel", None, QtGui.QApplication.UnicodeUTF8)) self.cancelButton.setIcon(getThemeIcon("process-stop")) self.cancelButton.setToolTip("Cancel") addForm.resize(250, 150) QtCore.QObject.connect(self.addButton,QtCore.SIGNAL("clicked()"), self.onAdd) QtCore.QObject.connect(self.cancelButton,QtCore.SIGNAL("clicked()"), self.onCancel) QtCore.QObject.connect(self.smsCheckBox,QtCore.SIGNAL("stateChanged(int)"), self.onCheckStateChanged)
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 setupUi(self, row_widget): self.row_widget = row_widget row_widget.setObjectName("row_widget") row_widget.resize(382, 31) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(row_widget.sizePolicy().hasHeightForWidth()) row_widget.setSizePolicy(sizePolicy) self.gridLayout = QtGui.QGridLayout(row_widget) self.gridLayout.setMargin(0) self.gridLayout.setObjectName("gridLayout") self.valueCombo = QtGui.QComboBox(row_widget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.valueCombo.sizePolicy().hasHeightForWidth()) self.valueCombo.setSizePolicy(sizePolicy) self.valueCombo.setObjectName("valueCombo") self.valueCombo.addItem(QtCore.QString()) self.valueCombo.setItemText(0, "") self.valueCombo.addItem(QtCore.QString("<")) self.valueCombo.addItem(QtCore.QString("<=")) self.valueCombo.addItem(QtCore.QString("==")) self.valueCombo.addItem(QtCore.QString(">")) self.valueCombo.addItem(QtCore.QString(">=")) self.valueCombo.addItem(QtCore.QString("!=")) self.gridLayout.addWidget(self.valueCombo, 1, 1, 1, 1) self.operatorCombo = QtGui.QComboBox(row_widget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.operatorCombo.sizePolicy().hasHeightForWidth()) self.operatorCombo.setSizePolicy(sizePolicy) self.operatorCombo.setEditable(True) self.operatorCombo.setFrame(True) self.operatorCombo.setObjectName("operatorCombo") self.gridLayout.addWidget(self.operatorCombo, 1, 2, 1, 1) self.variableCombo = QtGui.QComboBox(row_widget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.variableCombo.sizePolicy().hasHeightForWidth()) self.variableCombo.setSizePolicy(sizePolicy) self.variableCombo.setEditable(True) self.variableCombo.setObjectName("variableCombo") self.gridLayout.addWidget(self.variableCombo, 1, 0, 1, 1) self.removeButton = QtGui.QPushButton(row_widget) self.removeButton.setObjectName("removeButton") self.removeButton.setIcon(getThemeIcon("list-remove")) self.gridLayout.addWidget(self.removeButton, 1, 3, 1, 1) self.retranslateUi(row_widget) QtCore.QObject.connect(self.variableCombo, QtCore.SIGNAL("editTextChanged(QString)"), self.row_widget.CreateText) QtCore.QObject.connect(self.operatorCombo, QtCore.SIGNAL("editTextChanged(QString)"), self.row_widget.CreateText) QtCore.QObject.connect(self.valueCombo, QtCore.SIGNAL("currentIndexChanged(QString)"), self.row_widget.CreateText) QtCore.QMetaObject.connectSlotsByName(row_widget)
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, view=None, parent=None, designMode=False): FilterToolBar.__init__(self, view=view, parent=parent, designMode=designMode) self.getFilterLineEdit().setToolTip("Quick filter by log name") self._logLevelComboBox = logLevelComboBox = Qt.QComboBox() levels = "Trace", "Debug", "Info", "Warning", "Error", "Critical" for level in levels: logLevelComboBox.addItem(level, Qt.QVariant(getattr(taurus, level))) logLevelComboBox.setCurrentIndex(0) Qt.QObject.connect(logLevelComboBox, Qt.SIGNAL("currentIndexChanged(int)"), self.onLogLevelChanged) logLevelComboBox.setToolTip("Filter by log level") self._filterLevelAction = self.addWidget(logLevelComboBox) self.addSeparator() af = ActionFactory() self._scrollLockAction = af.createAction( self, "Refresh", icon=getThemeIcon("system-lock-screen"), tip="Scroll lock", toggled=self.onToggleScrollLock) self.addAction(self._scrollLockAction)
def test_icons(self): '''check that theme icons work''' from taurus.qt.qtgui.resource import getThemeIcon icon = getThemeIcon("folder-open") msg = ('Theme icons not available ' + '(if PyQt<4.6, make sure to build resources first!)') self.assertFalse(icon.isNull(), msg)
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: parent.connect(action, Qt.SIGNAL("triggered()"), triggered) if toggled is not None: parent.connect(action, Qt.SIGNAL("toggled(bool)"), toggled) action.setCheckable(True) if icon is not None: if isinstance(icon, (str, unicode)): icon = getThemeIcon(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, qt_parent=None, designMode=False): Qt.QWidget.__init__(self, qt_parent) self._history = CommandLineHistory() l = Qt.QHBoxLayout() self.setLayout(l) l.setContentsMargins(0, 0, 0, 0) l.setSpacing(0) self._detailsButton = Qt.QToolButton() self._detailsButton.setText("...") self._cmdLine = Qt.QComboBox() self._cmdLine.setEditable(True) self._applyButton = Qt.QToolButton() self._applyButton.setIcon(getIcon(":/actions/media_playback_start.svg")) self._stopButton = Qt.QToolButton() self._stopButton.setIcon(getIcon(":/actions/media_playback_stop.svg")) self._clearButton = Qt.QToolButton() self._clearButton.setIcon(getThemeIcon("edit-clear")) l.addWidget(self._detailsButton, 0) l.addWidget(self._cmdLine, 1) l.addWidget(self._applyButton, 0) l.addWidget(self._stopButton, 0) l.addWidget(self._clearButton, 0)
def contextMenuEvent(self, event): '''Reimplemented from :meth:`QWidget.contextMenuEvent`''' self.tree._toDeleteIndex = self.treeview.selectedIndexes()[0] text = Qt.from_qvariant(self.tree._toDeleteIndex.data(), str) if self.tree._toDeleteIndex.column() in [1, 2] or text in [ 'LAST', '[custom]' ] or text in self.tree.perspectives: return menu = Qt.QMenu() menu.addAction(getThemeIcon('process-stop'), "Delete branch: " + text, self.tree.deleteBranch) menu.addSeparator() menu.addAction(getThemeIcon('help-browser'), "Help") menu.exec_(event.globalPos()) event.accept()
def valueChanged(self, value, index): ''' Modifies value in the temporary settings file and the model internal dictionary. Invoked by :meth:`Qt.QAbstractTableModel.setData`, when user make changes to the value in the settings tree. :param value: (str) the new value (a string that will be python-evaluated) :param index: (QModelIndex) index of the model ''' changedItem = self.itemFromIndex(index) path = Qt.from_qvariant(changedItem.data(Qt.Qt.UserRole), str) self._configurationDictionaries = self.changeTreeValue( self._configurationDictionaries, path, value) try: group = eval(str(path).split(';', 1)[0]) except: group = str(path).split(';', 1)[0] itemToMark = self.itemFromIndex(index.sibling(index.row(), 0)) self.markedItems.append(itemToMark.index()) self.itemFromIndex(index.sibling(index.row(), 1)).setText(str(type(eval(value)))) changedItem.setData( Qt.QVariant('Value has been changed. Old value: ' + str(changedItem.text())), Qt.Qt.ToolTipRole) itemToMark.setData(Qt.QVariant(getThemeIcon('emblem-important')), Qt.Qt.DecorationRole) while (itemToMark is not None): itemToMark.setData( Qt.QVariant(Qt.QFont("Arial", 10, Qt.QFont.Bold)), Qt.Qt.FontRole) itemToMark = self.itemFromIndex(itemToMark.index().parent()) self.saveSettings(group)
def __init__(self, qt_parent=None, designMode=False): Qt.QWidget.__init__(self, qt_parent) self._history = CommandLineHistory() l = Qt.QHBoxLayout() self.setLayout(l) l.setContentsMargins(0, 0, 0, 0) l.setSpacing(0) self._detailsButton = Qt.QToolButton() self._detailsButton.setText("...") self._cmdLine = Qt.QComboBox() self._cmdLine.setEditable(True) self._applyButton = Qt.QToolButton() self._applyButton.setIcon( getIcon(":/actions/media_playback_start.svg")) self._stopButton = Qt.QToolButton() self._stopButton.setIcon(getIcon(":/actions/media_playback_stop.svg")) self._clearButton = Qt.QToolButton() self._clearButton.setIcon(getThemeIcon("edit-clear")) l.addWidget(self._detailsButton, 0) l.addWidget(self._cmdLine, 1) l.addWidget(self._applyButton, 0) l.addWidget(self._stopButton, 0) l.addWidget(self._clearButton, 0)
def retranslateUi(self, Form): Form.setWindowTitle(QtGui.QApplication.translate("Form", "Details", None, QtGui.QApplication.UnicodeUTF8)) self.refreshButton.setText(QtGui.QApplication.translate("Form", "Refresh", None, QtGui.QApplication.UnicodeUTF8)) self.refreshButton.setIcon(getThemeIcon("view-refresh")) self.refreshButton.setToolTip("Refresh list") QtCore.QObject.connect(self.refreshButton, QtCore.SIGNAL("clicked()"), self.onRefresh)
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 getQtDesignerPluginInfo(cls): from taurus.qt.qtgui.resource import getThemeIcon return { 'group': 'Taurus Help', 'icon': getThemeIcon("help"), 'module': 'taurus.qt.qtgui.help', 'container': False }
def retranslateUi(self, Form): Form.setWindowTitle(QtGui.QApplication.translate("Form", "Phonebook", None, QtGui.QApplication.UnicodeUTF8)) self.addButton.setText(QtGui.QApplication.translate("Form", "Add", None, QtGui.QApplication.UnicodeUTF8)) self.addButton.setIcon(getThemeIcon("list-add")) self.addButton.setToolTip("Add person to the list") self.removeButton.setText(QtGui.QApplication.translate("Form", "Remove", None, QtGui.QApplication.UnicodeUTF8)) self.removeButton.setIcon(getThemeIcon("list-remove")) self.removeButton.setToolTip("Remove person from list") self.refreshButton.setText(QtGui.QApplication.translate("Form", "Refresh", None, QtGui.QApplication.UnicodeUTF8)) self.refreshButton.setIcon(getThemeIcon("view-refresh")) self.refreshButton.setToolTip("Refresh list") QtCore.QObject.connect(self.tableWidget, QtCore.SIGNAL("itemDoubleClicked(QTableWidgetItem *)"), self.onEdit) QtCore.QObject.connect(self.addButton,QtCore.SIGNAL("clicked()"), self.onAdd) QtCore.QObject.connect(self.removeButton,QtCore.SIGNAL("clicked()"), self.onRemove) QtCore.QObject.connect(self.refreshButton,QtCore.SIGNAL("clicked()"), self.onRefresh) Form.resize(430, 800)
def __init__(self, parent=None, designMode=False): Qsci.QsciScintilla.__init__(self, parent) self.textEdit = Qsci.QsciScintilla() self.textEdit.setAutoCompletionThreshold(1) self.textEdit.setAutoCompletionSource(Qsci.QsciScintilla.AcsAll) self.textEdit.setAutoIndent(True) self.textEdit.setCallTipsStyle(Qsci.QsciScintilla.CallTipsContext) self.textEdit.setCallTipsVisible(0) self.pythonLexer = Qsci.QsciLexerPython(self.textEdit) self.api = Qsci.QsciAPIs(self.pythonLexer) self.api.add(Qt.QString("dupa(a,b)this is function dupa")) self.api.prepare() self.pythonLexer.setAPIs(self.api) self.textEdit.setLexer(self.pythonLexer) self.newAction = Qt.QAction(getThemeIcon("document-new"), "New", self) self.connect(self.newAction, Qt.SIGNAL("triggered()"), self.newFile) self.newAction.setToolTip("Create new file") self.newAction.setShortcut("Ctrl+N") self.openAction = Qt.QAction(getThemeIcon("document-open"), "Open", self) self.connect(self.openAction, Qt.SIGNAL("triggered()"), self.openFile) self.openAction.setToolTip("Open existing file") self.openAction.setShortcut("Ctrl+O") self.saveAction = Qt.QAction(getThemeIcon("document-save"), "Save", self) self.connect(self.saveAction, Qt.SIGNAL("triggered()"), self.saveFile) self.saveAction.setToolTip("Save document to disk") self.saveAction.setShortcut("Ctrl+S") self.saveAsAction = Qt.QAction(getThemeIcon("document-save-as"), "Save as...", self) self.connect(self.saveAsAction, Qt.SIGNAL("triggered()"), self.saveFile) self.saveAsAction.setToolTip("Save document under a new name") self.cutAction = Qt.QAction(getThemeIcon("edit-cut"), "Cut", self) self.connect(self.cutAction, Qt.SIGNAL("triggered()"), self.cut) self.cutAction.setToolTip("Cut current selection's contents to the clipboard") self.cutAction.setShortcut("Ctrl+X") self.cutAction.setEnabled(False) self.copyAction = Qt.QAction(getThemeIcon("edit-copy"), "Copy", self) self.connect(self.copyAction, Qt.SIGNAL("triggered()"), self.copy) self.copyAction.setToolTip("Copy current selection's contents to the clipboard") self.copyAction.setShortcut("Ctrl+C") self.copyAction.setEnabled(False) self.pasteAction = Qt.QAction(getThemeIcon("edit-paste"), "Paste", self) self.connect(self.pasteAction, Qt.SIGNAL("triggered()"), self.paste) self.pasteAction.setToolTip("Paste the clipboard's contents into the current selection") self.pasteAction.setShortcut("Ctrl+V") self.aboutAction = Qt.QAction("About", self) self.connect(self.aboutAction, Qt.SIGNAL("triggered()"), self.about) self.aboutAction.setToolTip("Show the application's About box") self.connect(self.textEdit, Qt.SIGNAL("copyAvailable(bool)"), self.cutAction.setEnabled) self.connect(self.textEdit, Qt.SIGNAL("copyAvailable(bool)"), self.copyAction.setEnabled) self.setCurrentFile("")
def __init__(self, parent=None, designMode=False): TaurusWidget.__init__(self, parent=parent, designMode=designMode) self.setLayout(Qt.QVBoxLayout()) self.tree = QConfigEditorModel() self.treeview = Qt.QTreeView() self.tree.setHorizontalHeaderLabels( ['Configuration key', 'type', 'value']) self.layout().addWidget(self.treeview) self._toolbar = Qt.QToolBar("QConfigViewer Main toolBar") self._toolbar.addAction(getThemeIcon("document-open"), "Open File", self.loadFile) self._toolbar.addAction(getThemeIcon("document-save"), "Save File", self.saveFile) self._toolbar.addAction(getThemeIcon("edit-undo"), "Reload from file", self.restoreOriginal) self.layout().setMenuBar(self._toolbar) self.setWindowTitle('TaurusConfigEditor') self.connect(self.tree, Qt.SIGNAL("showError"), self._showError)
def onTableContextMenu(self, pos): index = self.ui.curvesTable.indexAt(pos) row = index.row() menu = Qt.QMenu(self.ui.curvesTable) if row >= 0: removeThisAction = menu.addAction(getThemeIcon('list-remove'), 'Remove this curve', self._onRemoveThisAction) removeAllAction = menu.addAction(getThemeIcon('edit-clear'), 'Clear all', self.model.clearAll) addRowAction = menu.addAction(getThemeIcon('list-add'), 'Add new row', self.model.insertRows) if row >= 0: editParsAction = menu.addAction( getThemeIcon('preferences-system'), 'Edit parameters of this curve...', self._onEditParsAction) menu.exec_(Qt.QCursor.pos())
def __init__(self, view=None, parent=None, designMode=False): BaseToolBar.__init__(self, name="Taurus selection toolbar", view=view, parent=parent, designMode=designMode) af = ActionFactory() self._selectAllAction = af.createAction(self, "Select All", icon=getThemeIcon( "edit-select-all"), tip="Select all items", triggered=self.onSelectAll) self._clearSelectionAction = af.createAction(self, "Clear selection", icon=getThemeIcon( "edit-clear"), tip="Clears current selection", triggered=self.onclearSelection) self.addAction(self._selectAllAction) self.addAction(self._clearSelectionAction)
def setSrc(self, src): '''processes the src and sets the values of _src, display, icon and ok attributes''' if src is None: self._src, self.display, self.icon, self.ok = '', '(Empty)', Qt.QIcon( ), True return src = str(src).strip() if src == self._src: return self._src = src # empty if src == '': self.display, self.icon, self.ok = '(Empty)', Qt.QIcon(), True return # TODO tango-centric. For tango devices try: dev = taurus.Device(src) if dev.getDeviceProxy() is not None: self.display, self.icon, self.ok = dev.getSimpleName( ), getElementTypeIcon(TaurusElementType.Device), True return else: self.display, self.icon, self.ok = src, getThemeIcon( 'network-error'), False return except: # for tango attributes try: attr = taurus.Attribute(src) dev = attr.getParentObj() except TaurusException: self.display, self.icon, self.ok = src, getThemeIcon( 'dialog-warning'), False return except Exception: # @todo: this catchall except is here as an emergency bugfix, but should probably be narrowed to PyTango DevFailed. self.display, self.icon, self.ok = src, getThemeIcon( 'network-error'), False return if dev.getDeviceProxy() is None: self.display, self.icon, self.ok = src, getThemeIcon( 'network-error'), False return self.display, self.icon, self.ok = attr.getSimpleName( ), getElementTypeIcon(TaurusElementType.Attribute), True
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(getThemeIcon("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(getThemeIcon("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(getThemeIcon("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(getThemeIcon("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(getThemeIcon("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 __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( getThemeIcon("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(getThemeIcon("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( getThemeIcon("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( getThemeIcon("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( getThemeIcon("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 __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 retranslateUi(self, Form): Form.setWindowTitle(QtGui.QApplication.translate("Form", "PyAlarm Device Configuration", None, QtGui.QApplication.UnicodeUTF8)) self.refreshButton.setText(QtGui.QApplication.translate("Form", "Refresh", None, QtGui.QApplication.UnicodeUTF8)) self.refreshButton.setIcon(getThemeIcon("view-refresh")) self.refreshButton.setToolTip("Refresh list") QtCore.QObject.connect(self.tableWidget, QtCore.SIGNAL("itemChanged(QTableWidgetItem *)"), self.onEdit) QtCore.QObject.connect(self.deviceCombo, QtCore.SIGNAL("currentIndexChanged(QString)"), self.buildList) QtCore.QObject.connect(self.refreshButton, QtCore.SIGNAL("clicked()"), self.buildList) Form.resize(430, 600)
def __init__(self, view=None, parent=None, designMode=False): BaseToolBar.__init__(self, name="Taurus refresh toolbar", view=view, parent=parent, designMode=designMode) af = ActionFactory() self._refreshAction = af.createAction(self, "Refresh", icon=getThemeIcon( "view-refresh"), tip="Refresh view", triggered=self.onRefresh) self.addAction(self._refreshAction)
def prepareLineWidget(self): #Setup of the State/Details/Reset line in the editor widget self.w = Qt.QWidget() self.w.setLayout(Qt.QHBoxLayout()) self._tvl = AlarmValueLabel(self.w) self._tvl.setShowQuality(False) self._detailsButton = Qt.QPushButton(self.w) self._detailsButton.setText('Last Report') self._detailsButton.setIcon(getThemeIcon("edit-find")) self._detailsButton.connect(self._detailsButton,Qt.SIGNAL("clicked()"),self.showAlarmReport) self._detailsButton.setEnabled(False) self._resetButton = Qt.QPushButton(self.w) self._resetButton.setText('Reset') self._resetButton.setIcon(getThemeIcon("edit-undo")) self._resetButton.connect(self._resetButton,Qt.SIGNAL("clicked()"),self.ResetAlarm) self._resetButton.setEnabled(False) self.w.layout().addWidget(self._tvl) self.w.layout().addWidget(self._detailsButton) self.w.layout().addWidget(self._resetButton) self._dataWidget._wi.horizontalLane.addWidget(self.w)
def getElementTypeIcon(t): if t == ChannelView.Channel: return getIcon(":/actions/system-shutdown.svg") elif t == ChannelView.Enabled: return getIcon(":/status/true.svg") elif t == ChannelView.Output: return getThemeIcon("utilities-terminal") elif t == ChannelView.PlotType: return getIcon(":/apps/utilities-system-monitor.svg") elif t == ChannelView.PlotAxes: return getIcon(":/apps/utilities-system-monitor.svg") elif t == ChannelView.Timer: return getIcon(":/status/flag-green-clock.svg") elif t == ChannelView.Monitor: return getIcon(":/status/flag-green.svg") elif t == ChannelView.Trigger: return getIcon(":/actions/system-shutdown.svg") elif t == ChannelView.NXPath: return getThemeIcon("document-save-as") return getIcon(":/tango.png")
def setFontsAndColors(klass,tag,icon,bold,color,background): #print 'setFontsAndColors(%s,%s,%s,%s,%s)'%(tag,icon,bold,color.name(),background.name()) tag = str(tag).lower() if tag in klass.ALL_ROWS: self = klass.ALL_ROWS[tag] self.alarmIcon=getThemeIcon(icon) if icon else None self.setIcon(self.alarmIcon or Qt.QIcon()) self.font.setBold(bold) self.setTextColor(color) self.setBackgroundColor(background) else: print 'Tag %s is not in the list of AlarmRows: %s' % (tag,klass.ALL_ROWS.keys())
def main(): app = Qt.QApplication([]) app.setApplicationName("Example GUI") app.setApplicationVersion("1.2.3") app.setOrganizationName("Taurus") app.setOrganizationDomain("http://www.taurus-scada.org/") about_dialog = AboutDialog() # about_dialog.setText(txt) from taurus.qt.qtgui.resource import getThemeIcon pixmap = getThemeIcon("folder-open").pixmap(64, 64) about_dialog.setPixmap(pixmap) about_dialog.exec_()
def processSrc(self, src): '''returns src,display,icon,ok''' src = unicode(src) # empty if src == '': return '', '', Qt.QIcon(), True # for formulas if src.startswith('='): #@todo: evaluate/validate the expression return src, src[1:].strip(), getThemeIcon( 'accessories-calculator'), True # for tango attributes if self._attrnamevalidator.isValid(src): pars = self._attrnamevalidator.getUriGroups(src) dev = self._dbCache.getDevice(pars['devname']) if dev is None: return src, src, getThemeIcon('network-error'), False attr = dev.getAttribute(pars['_shortattrname']) if attr is None: return src, pars['_shortattrname'], getThemeIcon( 'network-error'), False return src, attr.name(), getThemeIcon('network-server'), True # for nexus files m = re.match(NEXUS_SRC, src) if m is not None: host, path, nxpath, slice = m.group(4, 5, 9, 10) #@todo:open file and check the data is accessible return src, nxpath, getThemeIcon('x-office-spreadsheet'), True # for ascii files m = re.match(ASCII_SRC, src) if m is not None: host, path, = m.group(4, 5) #@todo: open and check the file # If nothing matches... return src, src, getThemeIcon('dialog-warning'), False
def __init__(self, parent=None, paramModel=None): ParamBase.__init__(self, paramModel) Qt.QWidget.__init__(self, parent) self.setLayout(Qt.QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) addNewColumnButton = Qt.QPushButton(getThemeIcon("list-add") , "Add new column...", self) removeSelectedColumnsButton = Qt.QPushButton(getThemeIcon("list-remove") , "Remove selected...", self) buttonsLayout = Qt.QHBoxLayout() buttonsLayout.addWidget(addNewColumnButton) buttonsLayout.addWidget(removeSelectedColumnsButton) self.layout().addLayout(buttonsLayout) self.extraColumnsTable = ExtraColumnsTable(self) self.extraColumnsModel = ExtraColumnsModel() self.extraColumnsTable.setModel(self.extraColumnsModel) self.extraColumnsTable.setItemDelegate(ExtraColumnsDelegate(self.extraColumnsTable)) self.layout().addWidget(self.extraColumnsTable) self.connect(addNewColumnButton, Qt.SIGNAL("clicked()"), self.onAddNewColumn) self.connect(removeSelectedColumnsButton, Qt.SIGNAL("clicked()"), self.onRemoveSelectedColumns) self.connect(self.extraColumnsModel, Qt.SIGNAL("dataChanged (const QModelIndex&,const QModelIndex&)"), self.onExtraColumnsChanged) self.connect(self.extraColumnsModel, Qt.SIGNAL("modelReset()"), self.onExtraColumnsChanged)
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.disableActions()
def initStyle(self): print 'In AttributesPreview.initStyle()' try: self.setLayout(Qt.QGridLayout()) self.redobt = Qt.QPushButton() self.redobt.setIcon(resource.getThemeIcon('view-refresh')) self.redobt.setToolTip('Update result') self.taurusForm=TaurusForm() self.taurusForm.setWithButtons(False) self.taurusForm.setWindowTitle('Preview') self.layout().addWidget(self.redobt,0,6,1,1) self.layout().addWidget(Qt.QLabel('Values of attributes used in the Alarm formula:'),0,0,1,1) self.layout().addWidget(self.taurusForm,1,0,1,7) self.connect(self.redobt,Qt.SIGNAL('pressed()'),self.updateAttributes) except: print traceback.format_exc()
def onContextMenu(self, point): self.popMenu = QtGui.QMenu(self) items = self.getSelectedRows(extend=False) print('In onContextMenu(%s)'%items) row = self._ui.listWidget.currentItem() #self.popMenu.addAction(getThemeIcon("face-glasses"), "Preview Attr. Values",self.onSelectAll) act = self.popMenu.addAction(getThemeIcon("face-glasses"),"See Alarm Details",self.onView) act.setEnabled(len(items)==1) act = self.popMenu.addAction(getThemeIcon("accessories-calculator"),"Preview Formula/Values", lambda s=self:WindowManager.addWindow(s.showAlarmPreview())) act.setEnabled(len(items)==1) self.popMenu.addAction(getThemeIcon("view-refresh"), "Sort/Update List",self.onSevFilter) if SNAP_ALLOWED and row.get_alarm_tag() in self.ctx_names: act = self.popMenu.addAction(getThemeIcon("office-calendar"), "View History",self.viewHistory) act.setEnabled(len(items)==1) sevMenu = self.popMenu.addMenu('Change Severity') for S in ('ERROR','ALARM','WARNING','DEBUG'): action = sevMenu.addAction(S) self.connect(action, QtCore.SIGNAL("triggered()"), lambda ks=items,s=S: self.setSeverity([k.get_alarm_tag() for k in ks],s)) # Reset / Acknowledge options act = self.popMenu.addAction(getThemeIcon("edit-undo"), "Reset Alarm(s)",self.ResetAlarm) act.setEnabled(any(i.alarm.active for i in items)) if len([i.alarmAcknowledged for i in items]) in (len(items),0): self.popMenu.addAction(getThemeIcon("media-playback-pause"), "Acknowledge/Renounce Alarm(s)",self.onAckStateChanged) #(lambda checked=not row.alarmAcknowledged:self.onAckStateChanged(checked))) if len([i.alarmDisabled for i in items]) in (len(items),0): self.popMenu.addAction(getThemeIcon("dialog-error"), "Disable/Enable Alarm(s)",self.onDisStateChanged) # Edit options if self.expert: self.popMenu.addSeparator() act = self.popMenu.addAction(getThemeIcon("accessories-text-editor"), "Edit Alarm",self.onEdit) act.setEnabled(len(items)==1) act = self.popMenu.addAction(getThemeIcon("edit-copy"), "Clone Alarm",self.onClone) act.setEnabled(len(items)==1) act = self.popMenu.addAction(getThemeIcon("edit-clear"), "Delete Alarm",self.onDelete) act.setEnabled(len(items)==1) self.popMenu.addAction(getThemeIcon("applications-system"), "Advanced Config",self.onConfig) self.popMenu.addSeparator() act = self.popMenu.addAction(getThemeIcon("accessories-text-editor"), "TestDevice",lambda d=row.alarm.device:os.system('tg_devtest %s &'%d)) act.setEnabled(len(items)==1) #self.popMenu.addSeparator() #self.popMenu.addAction(getThemeIcon("process-stop"), "close App",self.close) self.popMenu.exec_(self._ui.listWidget.mapToGlobal(point))
def main(args=[]): import widgets from taurus.qt.qtgui import resource # print os.getenv('TANGO_HOST') print '='*80 trace(' Launching Panic ...') print '='*80 opts = [a for a in args if a.startswith('--')] args = [a for a in args if not a.startswith('--')] URL = 'http://www.cells.es/Intranet/Divisions/Computing/Controls/Help/Alarms/panic' uniqueapp = Qt.QApplication([]) if '--calc' in opts: args = args or [''] form = AlarmPreview(*args) form.show() uniqueapp.exec_() return tmw = CleanMainWindow() tmw.setWindowTitle('PANIC') #str(os.getenv('TANGO_HOST')).split(':',1)[0]+' ) tmw.menuBar = Qt.QMenuBar(tmw) tmw.toolsMenu = Qt.QMenu('Tools',tmw.menuBar) tmw.fileMenu = Qt.QMenu('File',tmw.menuBar) tmw.viewMenu = Qt.QMenu('View',tmw.menuBar) tmw.helpMenu = Qt.QMenu('Help',tmw.menuBar) trace('\tlaunching AlarmGUI ... %s'%sys.argv) alarmApp = AlarmGUI(filters='|'.join(a for a in sys.argv[1:] if not a.startswith('--')),options=opts,mainwindow=tmw) tmw.setCentralWidget(alarmApp) tmw.setMenuBar(tmw.menuBar) [tmw.menuBar.addAction(a.menuAction()) for a in (tmw.fileMenu,tmw.toolsMenu,tmw.helpMenu,tmw.viewMenu)] toolbar = Qt.QToolBar(tmw) toolbar.setIconSize(Qt.QSize(20,20)) tmw.helpMenu.addAction(getThemeIcon("applications-system"),"Webpage",lambda : os.system('konqueror %s &'%URL)) tmw.toolsMenu.addAction(getThemeIcon("applications-system"),"Jive",lambda : os.system('jive &')) tmw.toolsMenu.addAction(getThemeIcon("applications-system"),"Astor",lambda : os.system('astor &')) tmw.fileMenu.addAction(resource.getIcon(":/designer/back.png"),"Export to CSV file",alarmApp.saveToFile) tmw.fileMenu.addAction(resource.getIcon(":/designer/forward.png"),"Import from CSV file",alarmApp.loadFromFile) tmw.fileMenu.addAction(resource.getIcon(":/designer/filereader.png"),"Use external editor",alarmApp.editFile) tmw.fileMenu.addAction(getThemeIcon("applications-system"),"Exit",tmw.close) tmw.viewMenu.connect(tmw.viewMenu,Qt.SIGNAL('aboutToShow()'),alarmApp.setViewMenu) from phonebook import PhoneBook alarmApp.tools['bookApp'] = WindowManager.addWindow(PhoneBook(container=tmw)) tmw.toolsMenu.addAction(getThemeIcon("x-office-address-book"), "PhoneBook", alarmApp.tools['bookApp'].show) toolbar.addAction(getThemeIcon("x-office-address-book") ,"PhoneBook",alarmApp.tools['bookApp'].show) trend_action = (resource.getIcon(":/designer/qwtplot.png"), 'Trend', lambda:WindowManager.addWindow(widgets.get_archive_trend(show=True)) ) tmw.toolsMenu.addAction(*trend_action) toolbar.addAction(*trend_action) alarmApp.tools['config'] = WindowManager.addWindow(widgets.dacWidget(container=tmw)) tmw.toolsMenu.addAction(getThemeIcon("applications-system"),"Advanced Configuration", alarmApp.tools['config'].show) toolbar.addAction(getThemeIcon("applications-system") ,"Advanced Configuration",alarmApp.tools['config'].show) toolbar.setMovable(False) toolbar.setFloatable(False) tmw.addToolBar(toolbar) if SNAP_ALLOWED: alarmApp.tools['history'] = WindowManager.addWindow(widgets.ahWidget(container=tmw)) tmw.toolsMenu.addAction(getThemeIcon("office-calendar"),"Alarm History Viewer",alarmApp.tools['history'].show) toolbar.addAction(getThemeIcon("office-calendar") ,"Alarm History Viewer",alarmApp.tools['history'].show) else: trace("Unable to load SNAP",'History Viewer Disabled!') alarm_preview_action = (getThemeIcon("accessories-calculator"),"Alarm Calculator", lambda g=alarmApp:WindowManager.addWindow(AlarmPreview.showEmptyAlarmPreview(g))) [o.addAction(*alarm_preview_action) for o in (tmw.toolsMenu,toolbar)] tmw.show() return uniqueapp #.exec_()
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 setupUi(self, Data): self.Data=Data Data.setObjectName("Data") Data.resize(349, 275) self.verticalLayout_3 = QtGui.QVBoxLayout(Data) self.verticalLayout_3.setObjectName("verticalLayout_3") self.gridLayout = QtGui.QGridLayout() self.gridLayout.setObjectName("gridLayout") self.font = QtGui.QFont() self.font.setBold(True) self.nameLabel = QtGui.QLabel(Data) self.nameLabel.setObjectName("nameLabel") self.nameLabel.setFont(self.font) self.gridLayout.addWidget(self.nameLabel, 0, 0, 1, 1) self.nameLineEdit = clickableQLineEdit(Data) self.nameLineEdit.setReadOnly(True) self.nameLineEdit.setObjectName("nameLineEdit") self.nameLineEdit.setFont(self.font) self.gridLayout.addWidget(self.nameLineEdit, 0, 1, 1, 3) self.statusLabel = QtGui.QLabel(Data) self.statusLabel.setObjectName("statusLabel") self.gridLayout.addWidget(self.statusLabel, 1, 0, 1, 1) self.horizontalLane = QtGui.QHBoxLayout() self.horizontalLane.setObjectName("horizontalLayout") self.gridLayout.addLayout(self.horizontalLane, 1, 1, 1, 3) self.disableLabel = QtGui.QLabel(Data) self.disableLabel.setObjectName("disableLabel") self.gridLayout.addWidget(self.disableLabel, 2, 0, 1, 1) self.disabledCheckBox = QtGui.QCheckBox(Data) self.disabledCheckBox.setObjectName("disabledCheckBox") self.gridLayout.addWidget(self.disabledCheckBox, 2, 1, 1, 1) self.disabledCheckBox.setEnabled(False) self.ackLabel = QtGui.QLabel(Data) self.ackLabel.setObjectName("ackLabel") self.gridLayout.addWidget(self.ackLabel, 3, 0, 1, 1) self.ackCheckBox = QtGui.QCheckBox(Data) self.ackCheckBox.setObjectName("ackCheckBox") self.gridLayout.addWidget(self.ackCheckBox, 3, 1, 1, 1) self.ackCheckBox.setEnabled(False) self.deviceLabel = QtGui.QLabel(Data) self.deviceLabel.setObjectName("deviceLabel") self.gridLayout.addWidget(self.deviceLabel, 4, 0, 1, 1) self.deviceStackedLayout = QtGui.QStackedLayout() self.deviceStackedLayout.setObjectName("deviceStackedLayout") self.deviceCombo = QtGui.QComboBox(Data) self.deviceCombo.setObjectName("deviceCombo") self.deviceStackedLayout.addWidget(self.deviceCombo) self.deviceLineEdit = clickableQLineEdit(Data) self.deviceLineEdit.setReadOnly(True) self.deviceLineEdit.setObjectName("deviceLineEdit") self.deviceStackedLayout.addWidget(self.deviceLineEdit) self.deviceStackedLayout.setCurrentIndex(1) self.gridLayout.addLayout(self.deviceStackedLayout, 4, 1, 1, 2) self.deviceConfig = QtGui.QPushButton(Data) self.deviceConfig.setIcon(getThemeIcon("applications-system")) self.gridLayout.addWidget(self.deviceConfig, 4, 3, 1, 1) self.severityLabel = QtGui.QLabel(Data) self.severityLabel.setObjectName("severityLabel") self.gridLayout.addWidget(self.severityLabel, 5, 0, 1, 1) self.severityStackedLayout = QtGui.QStackedLayout() self.severityStackedLayout.setObjectName("severityStackedLayout") self.severityCombo=QtGui.QComboBox(Data) self.severityCombo.setObjectName("severityCombo") #self.severityCombo.connect(self.severityCombo,Q.textChanged,self.severityLineEdit.setText) self.severityStackedLayout.addWidget(self.severityCombo) self.severityLineEdit=clickableQLineEdit(Data) self.severityLineEdit.setReadOnly(True) self.severityLineEdit.setObjectName("severityLineEdit") self.severityStackedLayout.addWidget(self.severityLineEdit) self.severityStackedLayout.setCurrentIndex(1) self.gridLayout.addLayout(self.severityStackedLayout, 5, 1, 1, 3) self.descriptionLabel = QtGui.QLabel(Data) self.descriptionLabel.setObjectName("descriptionLabel") self.descriptionLabel.setMinimumWidth(70) self.gridLayout.addWidget(self.descriptionLabel, 6, 0, 1, 1) self.descriptionTextEdit = clickableQTextEdit(Data) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.descriptionTextEdit.sizePolicy().hasHeightForWidth()) self.descriptionTextEdit.setSizePolicy(sizePolicy) self.descriptionTextEdit.setMinimumSize(QtCore.QSize(0, 25)) self.descriptionTextEdit.setReadOnly(True) self.descriptionTextEdit.setObjectName("descriptionTextEdit") self.gridLayout.addWidget(self.descriptionTextEdit, 6, 1, 1, 3) self.receiversLabel = QtGui.QLabel(Data) self.receiversLabel.setObjectName("receiversLabel") self.gridLayout.addWidget(self.receiversLabel, 7, 0, 1, 1) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.receiversStackedLayout = QtGui.QStackedLayout() self.receiversStackedLayout.setObjectName("receiversStackedLayout") self.receiversLineEdit = clickableQLineEdit(Data) self.receiversLineEdit.setReadOnly(True) self.receiversLineEdit.setObjectName("receiversLineEdit") self.receiversLineEdit.setSizePolicy(sizePolicy) self.receiversStackedLayout.addWidget(self.receiversLineEdit) self.receiversWidget = QtGui.QWidget(Data) self.receiversWidget.setObjectName("receiversWidget") # self.receiversStackedLayout.addWidget(self.receiversWidget) self.receiversStackedLayout.setCurrentIndex(0) self.horizontalLayout.addLayout(self.receiversStackedLayout) self.addReceiversButton = QtGui.QPushButton(Data) self.addReceiversButton.setObjectName("addReceiversButton") self.addReceiversButton.setIcon(getThemeIcon("list-add")) self.horizontalLayout.addWidget(self.addReceiversButton) self.addReceiversButton.setEnabled(False) self.gridLayout.addLayout(self.horizontalLayout, 7, 1, 1, 1) self.verticalLayout_3.addLayout(self.gridLayout) self.frame = QtGui.QFrame(Data) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.frame.sizePolicy().hasHeightForWidth()) self.frame.setSizePolicy(sizePolicy) self.frame.setFrameShape(QtGui.QFrame.StyledPanel) self.frame.setFrameShadow(QtGui.QFrame.Raised) self.frame.setObjectName("frame") self.formulaStacked = QtGui.QStackedLayout(self.frame) self.formulaStacked.setObjectName("stackedLayout") self.formulaWidget = QtGui.QWidget(self.frame) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.formulaWidget.sizePolicy().hasHeightForWidth()) self.formulaWidget.setSizePolicy(sizePolicy) self.formulaWidget.setObjectName("formulaWidget") self.formulaStacked.addWidget(self.formulaWidget) # ad widget to stacked self.verticalLayout_2 = QtGui.QVBoxLayout(self.formulaWidget) self.verticalLayout_2.setObjectName("verticalLayout_2") self.formulaLabel = QtGui.QLabel()#self.formulaWidget) #self.font = QtGui.QFont() #self.font.setPointSize(8) #self.font.setWeight(75) #self.font.setBold(True) #self.formulaLabel.setFont(self.font) #self.formulaLabel.setObjectName("formulaLabel") #self.verticalLayout_2.addWidget(self.formulaLabel) from widgets import AlarmFormula self.formulaTextEdit = AlarmFormula() #clickableQTextEdit(self.formulaWidget) self.formulaTextEdit.setReadOnly(True) self.formulaTextEdit.setObjectName("formulaTextEdit") self.verticalLayout_2.addWidget(self.formulaTextEdit) self.verticalLayout_3.addWidget(self.frame) self.gridLayout_2 = QtGui.QGridLayout() self.gridLayout_2.setObjectName("gridLayout_2") self.spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.gridLayout_2.addItem(self.spacerItem, 0, 2, 1, 1) self.editButton = QtGui.QPushButton(Data) self.font = QtGui.QFont() self.font.setPointSize(8) self.editButton.setFont(self.font) self.editButton.setObjectName("editButton") self.editButton.setIcon(getThemeIcon("accessories-text-editor")) self.gridLayout_2.addWidget(self.editButton, 0, 0, 1, 1) self.previewButton = QtGui.QPushButton(Data) self.font = QtGui.QFont() self.font.setPointSize(8) self.previewButton.setFont(self.font) self.previewButton.setObjectName("previewButton") self.previewButton.setIcon(getThemeIcon("face-glasses")) self.gridLayout_2.addWidget(self.previewButton, 0, 1, 1, 1) self.cancelButton = QtGui.QPushButton(Data) self.font = QtGui.QFont() self.font.setPointSize(8) self.cancelButton.setFont(self.font) self.cancelButton.setObjectName("cancelButton") self.cancelButton.setIcon(getThemeIcon("edit-delete")) self.gridLayout_2.addWidget(self.cancelButton, 0, 4, 1, 1) self.saveButton = QtGui.QPushButton(Data) self.font = QtGui.QFont() self.font.setPointSize(8) self.saveButton.setFont(self.font) self.saveButton.setObjectName("saveButton") self.saveButton.setIcon(getThemeIcon("document-save")) self.gridLayout_2.addWidget(self.saveButton, 0, 3, 1, 1) self.verticalLayout_3.addLayout(self.gridLayout_2) self.retranslateUi(Data) QtCore.QMetaObject.connectSlotsByName(Data)
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.addToFavouritesAction.triggered.connect(self.onAddToFavourites) self.addToFavouritesAction.setToolTip("Add to favourites") self.stopMacroAction = Qt.QAction( getIcon(":/actions/media_playback_stop.svg"), "Stop macro", self) self.stopMacroAction.triggered.connect(self.onStopMacro) self.stopMacroAction.setToolTip("Stop macro") self.pauseMacroAction = Qt.QAction( getIcon(":/actions/media_playback_pause.svg"), "Pause macro", self) self.pauseMacroAction.triggered.connect(self.onPauseMacro) self.pauseMacroAction.setToolTip("Pause macro") self.playMacroAction = Qt.QAction( getIcon(":/actions/media_playback_start.svg"), "Start macro", self) self.playMacroAction.triggered.connect(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) # Due to a limitation in the useParentModel architecture of Taurus, # the parent of historyMacrosViewer and favouritesMacrosEditor # must be recalculated. See more details in the taurus snippet code [1] # [1] https://raw.githubusercontent.com/taurus-org/taurus/develop/doc/source/devel/examples/parentmodel_issue_demo.py self.historyMacrosViewer.recheckTaurusParent() self.favouritesMacrosEditor.recheckTaurusParent() 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.macroComboBox.currentIndexChanged['QString'].connect( self.onMacroComboBoxChanged) self.favouritesMacrosEditor.list.favouriteSelected.connect( self.onFavouriteSelected) self.historyMacrosViewer.list.historySelected.connect( self.onHistorySelected) self.spockCommand.pressedReturn.connect(self.onPlayMacro) self.spockCommand.spockComboBox.connect(self.setComboBoxItem) self.spockCommand.elementUp.connect(self.setHistoryUp) self.spockCommand.elementDown.connect(self.setHistoryDown) self.spockCommand.expandTree.connect( self.standardMacroParametersEditor.tree.expandAll)
def setNewDevName(self): """Fill the devices list""" device= str(self.ui.lineEdit.text()) device += '*' try: items = list(self.getDb().get_device_exported(device)) except Exception,e: self.warning('Unable to contact with device %s: %s'%(device,str(e))) items=[] self.ui.devList.clear() devs=set([d.rsplit('/',1)[0].lower() for d in self.beingArchived]) for i in items: item=Qt.QListWidgetItem() item.setText(str(i)) if str(i).lower() in devs: item.setIcon(getThemeIcon("appointment-new")) self.ui.devList.addItem(item) self.connect(self.ui.devList, Qt.SIGNAL("itemSelectionChanged ()"), self.setAttributes) class historyButton(Qt.QPushButton): def __init__(self): Qt.QPushButton.__init__(self) self.setMaximumWidth(40) self.setIcon(getThemeIcon("appointment-new")) self.setToolTip('show history') self.connect(self, Qt.SIGNAL("clicked()"), self.onButtonClicked) def setModel(self, model): self.model=model def getModel(self):
def contextMenuEvent(self, event): menu = Qt.QMenu() action = menu.addAction(getThemeIcon( "view-refresh"), "Check door state", self.checkDoorState) menu.exec_(event.globalPos())
def __init__(self): Qt.QPushButton.__init__(self) self.setMaximumWidth(40) self.setIcon(getThemeIcon("appointment-new")) self.setToolTip('show history') self.connect(self, Qt.SIGNAL("clicked()"), self.onButtonClicked)
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 setupUi(self, Form): self.Form=Form Form.setObjectName("Form") #Form.resize(QtCore.QSize(900, 900)) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) #sizePolicy.setHorizontalStretch(100) #sizePolicy.setVerticalStretch(100) sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth()) Form.setSizePolicy(sizePolicy) Form.setMinimumSize(QtCore.QSize(250, 250)) Form.setSizeIncrement(QtCore.QSize(1, 1)) #self.splitWidget = Qt.QSplitter(Form) self.leftWidget = Qt.QWidget(Form)#self.splitWidget) #self.rightWidget = Qt.QWidget(self.splitWidget) #sForm.setBaseSize(QtCore.QSize(200, 200)) self.horizontalLayout_3 = QtGui.QHBoxLayout(Form) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.Form.setLayout(self.horizontalLayout_3) self.verticalLayout_2 = QtGui.QVBoxLayout() self.verticalLayout_2.setObjectName("verticalLayout_2") self.frame = QtGui.QFrame(Form) self.frame.setFrameShape(QtGui.QFrame.StyledPanel) self.frame.setFrameShadow(QtGui.QFrame.Raised) self.frame.setObjectName("frame") self.frame.setMinimumSize(QtCore.QSize(300, 200)) #--------------------------------------------------------------------------------------- self.leftGridLayout = QtGui.QGridLayout(self.frame) self.leftGridLayout.setObjectName("leftGridLayout") self.comboLabel = QtGui.QLabel(self.frame) self.comboLabel.setObjectName("comboLabel") #self.comboLabel.setMaximumSize(QtCore.QSize(50, 30)) self.comboLabel.hide() self.leftGridLayout.addWidget(self.comboLabel, 0,0,1,1) #<------------- self.contextComboBox = QtGui.QComboBox(self.frame) self.contextComboBox.setObjectName("contextComboBox") self.leftGridLayout.addWidget(self.contextComboBox,0,1,1,5) #<------------- #self.comboButton = QtGui.QPushButton(self.frame) #self.comboButton.setObjectName("comboButton") #self.leftGridLayout.addWidget(self.comboButton,0,5,1,1) #self.comboButton2 = QtGui.QPushButton(self.frame) #self.comboButton2.setObjectName("comboButton2") #self.leftGridLayout.addWidget(self.comboButton2,0,6,1,1) self.infoLabel0_1 = QtGui.QLabel(self.frame) self.infoLabel0_1.setObjectName("infoLabel0_1") #self.infoLabel0_1.setMinimumWidth(60) self.leftGridLayout.addWidget(self.infoLabel0_1, 1,0,1,1) #<------------- self.infoLabel0_1.hide() self.comboBoxx = QtGui.QComboBox(self.frame) self.comboBoxx.setObjectName("comboBoxx") self.leftGridLayout.addWidget(self.comboBoxx, 1,1,1,5) #<------------- self.comboBoxx.hide() self.infoLabel1_1 = QtGui.QLabel(self.frame) self.infoLabel1_1.setObjectName("infoLabel1_1") self.leftGridLayout.addWidget(self.infoLabel1_1, 2,0,1,1) #<------------- self.infoLabel1_1.hide() self.infoLabel1_2 = QtGui.QLabel(self.frame) self.infoLabel1_2.setObjectName("infoLabel1_2") self.leftGridLayout.addWidget(self.infoLabel1_2, 2,1,1,5) #<------------- self.infoLabel1_2.hide() self.regExGridLayout = QtGui.QGridLayout() self.regExLabel = QtGui.QLabel(self.frame) self.regExLabel.setObjectName("regExLabel") self.regExLabel.setText('Type a string to filter alarms') self.regExGridLayout.addWidget(self.regExLabel, 0,0,1,1) self.regExLine = QtGui.QLineEdit(self.frame) self.regExLine.setObjectName("regExLine") self.regExGridLayout.addWidget(self.regExLine, 0,1,1,3) self.regExUpdate = QtGui.QPushButton(self.frame) self.regExUpdate.setObjectName("regExUpdate") self.regExUpdate.setText("Update") self.regExGridLayout.addWidget(self.regExUpdate, 0,4,1,1) self.leftGridLayout.addLayout(self.regExGridLayout, 3,0,1,6) #<------------- self.gridFilterLayout = QtGui.QGridLayout() self.gridFilterLayout.addWidget(Qt.QLabel('Severities:'), 2,0,1,1) self.sevAlarmLabel = QtGui.QLabel(self.frame) self.sevAlarmLabel.setObjectName("sevAlarmLabel") self.sevAlarmLabel.setText('Alarm') #self.sevAlarmLabel.setAlignment(Qt.Qt.AlignHCenter) self.gridFilterLayout.addWidget(self.sevAlarmLabel, 1,1,1,1) self.sevErrorLabel = QtGui.QLabel(self.frame) self.sevErrorLabel.setObjectName("sevErrorLabel") self.sevErrorLabel.setText('Error') #self.sevErrorLabel.setAlignment(Qt.Qt.AlignHCenter) self.gridFilterLayout.addWidget(self.sevErrorLabel, 1,2,1,1) self.sevWarningLabel = QtGui.QLabel(self.frame) self.sevWarningLabel.setObjectName("sevWarningLabel") self.sevWarningLabel.setText('Warning') #self.sevWarningLabel.setAlignment(Qt.Qt.AlignHCenter) self.gridFilterLayout.addWidget(self.sevWarningLabel, 1,3,1,1) self.sevDebugLabel = QtGui.QLabel(self.frame) self.sevDebugLabel.setObjectName("sevDebugLabel") self.sevDebugLabel.setText('Debug') #self.sevDebugLabel.setAlignment(Qt.Qt.AlignHCenter) self.gridFilterLayout.addWidget(self.sevDebugLabel, 1,4,1,1) self.sevAlarmCheckBox = QtGui.QCheckBox() self.sevAlarmCheckBox.setObjectName("sevAlarmCheckBox") self.sevAlarmCheckBox.setChecked(True) #self.sevAlarmCheckBox.setAlignment(Qt.Qt.AlignHCenter) self.gridFilterLayout.addWidget(self.sevAlarmCheckBox, 2,1,1,1) self.sevErrorCheckBox = QtGui.QCheckBox() self.sevErrorCheckBox.setObjectName("sevErrorCheckBox") self.sevErrorCheckBox.setChecked(True) #self.sevErrorCheckBox.setAlignment(Qt.Qt.AlignHCenter) self.gridFilterLayout.addWidget(self.sevErrorCheckBox, 2,2,1,1) self.sevWarningCheckBox = QtGui.QCheckBox() self.sevWarningCheckBox.setObjectName("sevWarningCheckBox") self.sevWarningCheckBox.setChecked(True) #self.sevWarningCheckBox.setAlignment(Qt.Qt.AlignHCenter) self.gridFilterLayout.addWidget(self.sevWarningCheckBox, 2,3,1,1) self.sevDebugCheckBox = QtGui.QCheckBox() self.sevDebugCheckBox.setObjectName("sevDebugCheckBox") self.sevDebugCheckBox.setChecked(False) #self.sevDebugCheckBox.setAlignment(Qt.Qt.AlignHCenter) self.gridFilterLayout.addWidget(self.sevDebugCheckBox, 2,4,1,1) #self.formLayout.addItem(self.gridFilterLayout) self.leftGridLayout.addLayout(self.gridFilterLayout, 4,0,1,6) #<------------- #self.verticalLayout_3.addLayout(self.formLayout) self.listWidget = QtGui.QListWidget(self.frame) self.listWidget.setObjectName("listWidget") self.listWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.listWidget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) self.leftGridLayout.addWidget(self.listWidget, 5,0,1,6) #<------------- self.statusLabel = QtGui.QLabel('Loading ...') self.leftGridLayout.addWidget(self.statusLabel,6,0,1,2) #<------------- self.activeLabel = QtGui.QLabel(self.frame) self.activeLabel.setObjectName("activeLabel") self.activeLabel.setText('Show Active Only') #self.gridFilterLayout.addWidget(self.activeLabel, 1,5,1,1) self.leftGridLayout.addWidget(self.activeLabel, 6,2,1,1) #<------------- self.activeCheckBox = QtGui.QCheckBox() self.activeCheckBox.setObjectName("activeCheckBox") self.activeCheckBox.setChecked(False) #self.gridFilterLayout.addWidget(self.activeCheckBox, 2,5,1,1) self.leftGridLayout.addWidget(self.activeCheckBox, 6,3,1,1) #<------------- self.selectLabel = QtGui.QLabel(self.frame) self.selectLabel.setObjectName("selectLabel") self.selectLabel.setText('Select All/None') #self.selectLabel.setAlignment(Qt.Qt.AlignRight) #self.gridFilterLayout.addWidget(self.selectLabel, 1,0,1,1) self.leftGridLayout.addWidget(self.selectLabel, 6,4,1,1) #<------------- self.selectCheckBox = QtGui.QCheckBox() self.selectCheckBox.setObjectName("selectCheckBox") self.selectCheckBox.setChecked(False) #self.selectCheckBox.setAlignment(Qt.Qt.AlignHCenter) #self.gridFilterLayout.addWidget(self.selectCheckBox, 2,0,1,1) self.leftGridLayout.addWidget(self.selectCheckBox, 6,5,1,1) #<------------- #---------------------------------------------------------------------------------------------- self.verticalLayout_2.addWidget(self.frame) self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.refreshButton = QtGui.QPushButton(Form) self.refreshButton.setObjectName("refreshButton") self.horizontalLayout_2.addWidget(self.refreshButton) self.refreshButton.hide() self.newButton = QtGui.QPushButton(Form) self.newButton.setObjectName("newButton") self.horizontalLayout_2.addWidget(self.newButton) self.newButton.hide() self.deleteButton = QtGui.QPushButton(Form) self.deleteButton.setObjectName("deleteButton") self.horizontalLayout_2.addWidget(self.deleteButton) self.deleteButton.hide() self.customButton3 = QtGui.QPushButton(Form) self.customButton3.setObjectName("customButton3") self.horizontalLayout_2.addWidget(self.customButton3) self.customButton3.hide() self.verticalLayout_2.addLayout(self.horizontalLayout_2) #self.horizontalLayout_3.addLayout(self.verticalLayout_2) self.leftWidget.setLayout(self.verticalLayout_2) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") #self.horizontalLayout_5 = QtGui.QHBoxLayout() #self.horizontalLayout_5.setObjectName("horizontalLayout_5") #self.tableLabel = QtGui.QLabel(Form) #self.tableLabel.setObjectName("tableLabel") #self.horizontalLayout_5.addWidget(self.tableLabel) #self.tableLabel.hide() #self.tableLabel.setText("tableLabel") #self.viewComboBox = QtGui.QComboBox(Form) #self.viewComboBox.setObjectName("viewComboBox") #self.horizontalLayout_5.addWidget(self.viewComboBox) #self.viewComboBox.setLayoutDirection(QtCore.Qt.RightToLeft) #self.viewComboBox.addItem("Table View") #self.viewComboBox.addItem("Live View") #self.viewComboBox.addItem("Compare View") #self.viewComboBox.setMaximumWidth(115) #self.viewComboBox.hide() #self.verticalLayout.addLayout(self.horizontalLayout_5) self.frame_2 = QtGui.QFrame(Form) self.frame_2.setFrameShape(QtGui.QFrame.StyledPanel) self.frame_2.setFrameShadow(QtGui.QFrame.Raised) self.frame_2.setObjectName("frame_2") self.frame_2.setMinimumSize(QtCore.QSize(300, 200)) self.gridLayout = QtGui.QGridLayout(self.frame_2) self.gridLayout.setObjectName("gridLayout") #self.tableWidget = QtGui.QTableWidget(self.frame_2) #self.tableWidget.setObjectName("tableWidget") #self.tableWidget.setColumnCount(0) #self.tableWidget.setRowCount(0) #self.gridLayout.addWidget(self.tableWidget) #self.tableWidget.hide() #self.taurusForm = TaurusForm(self.frame_2) #self.taurusForm.setObjectName("taurusForm") #self.taurusForm.hide() self.frame_2.hide() self.verticalLayout.addWidget(self.frame_2) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") #self.customButton4 = QtGui.QPushButton(Form) #self.customButton4.setObjectName("customButton4") #self.horizontalLayout.addWidget(self.customButton4) #self.customButton4.hide() #self.customButton5 = QtGui.QPushButton(Form) #self.customButton5.setObjectName("customButton5") #self.horizontalLayout.addWidget(self.customButton5) #self.customButton5.hide() self.buttonClose = QtGui.QPushButton(Form) self.buttonClose.setObjectName("buttonClose") self.buttonClose.setText(QtGui.QApplication.translate("Form", "Close", None, QtGui.QApplication.UnicodeUTF8)) self.buttonClose.setToolTip(QtGui.QApplication.translate("Form", "Close Application", None, QtGui.QApplication.UnicodeUTF8)) self.icon_close = QtGui.QIcon(":/actions/process-stop.svg") self.buttonClose.setIcon(self.icon_close) self.buttonClose.hide() self.horizontalLayout.addWidget(self.buttonClose) self.verticalLayout.addLayout(self.horizontalLayout) #self.horizontalLayout_3.addLayout(self.verticalLayout) #self.rightWidget.setLayout(self.verticalLayout) #self.splitWidget.addWidget(self.leftWidget) #self.splitWidget.addWidget(self.rightWidget) self.horizontalLayout_3.addWidget(self.leftWidget)#splitWidget) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) self.actionExpert = Qt.QAction(None) self.actionExpert.setText('Expert View') self.actionExpert.setCheckable(True) self.actionExpert.setChecked(False) Form.setWindowTitle("Alarms") self.comboLabel.setText("Sort:") #self.comboButton.setText("View") self.refreshButton.setText("Refresh/Sort List") self.refreshButton.setIcon(getThemeIcon("view-refresh")) self.newButton.setText("New") self.newButton.setIcon(getThemeIcon("window-new")) self.deleteButton.setText("Delete") self.deleteButton.setIcon(getThemeIcon("edit-clear")) self.comboLabel.show() self.refreshButton.show() self.newButton.show() self.deleteButton.show() self.comboBoxx.show() self.infoLabel0_1.show() self.infoLabel1_1.show()