class Snap_Core_Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.setWindowModality(QtCore.Qt.WindowModal) Form.resize(600, 355) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(100) sizePolicy.setVerticalStretch(100) sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth()) Form.setSizePolicy(sizePolicy) Form.setMinimumSize(QtCore.QSize(1000, 500)) Form.setSizeIncrement(QtCore.QSize(1, 1)) Form.setBaseSize(QtCore.QSize(200, 200)) self.mainLayout = QtGui.QHBoxLayout(Form) self.mainLayout.setObjectName("mainLayout") self.splitter = QtGui.QSplitter() self.splitter.setChildrenCollapsible(False) self.mainLayout.addWidget(self.splitter) ###################### Left Panel 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.verticalLayout_3 = QtGui.QVBoxLayout(self.frame) self.verticalLayout_3.setObjectName("verticalLayout_3") self.horizontalLayoutFilter = QtGui.QHBoxLayout() self.horizontalLayoutFilter.setObjectName("horizontalLayoutFilter") self.filterLabel = QtGui.QLabel(self.frame) self.filterLabel.setObjectName("filterLabel") self.filterLabel.setMaximumSize(QtCore.QSize(50, 30)) self.horizontalLayoutFilter.addWidget(self.filterLabel) self.filterComboBox = QtGui.QComboBox(self.frame) self.filterComboBox.setObjectName("filterComboBox") self.horizontalLayoutFilter.addWidget(self.filterComboBox) self.filterComboBox2 = QtGui.QComboBox(self.frame) self.filterComboBox2.setObjectName("filterComboBox2") self.horizontalLayoutFilter.addWidget(self.filterComboBox2) self.refreshButton = QtGui.QPushButton(self.frame) self.refreshButton.setObjectName("refreshButton") self.refreshButton.setMaximumSize(QtCore.QSize(50, 30)) self.horizontalLayoutFilter.addWidget(self.refreshButton) self.verticalLayout_3.addLayout(self.horizontalLayoutFilter) self.horizontalLayout_4 = QtGui.QHBoxLayout() self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.comboLabel = QtGui.QLabel(self.frame) self.comboLabel.setObjectName("comboLabel") self.comboLabel.setMaximumSize(QtCore.QSize(50, 30)) self.comboLabel.hide() self.horizontalLayout_4.addWidget(self.comboLabel) self.contextComboBox = QtGui.QComboBox(self.frame) self.contextComboBox.setObjectName("contextComboBox") self.horizontalLayout_4.addWidget(self.contextComboBox) self.ctxbuttonsLayout = QtGui.QHBoxLayout() self.buttonNew = QtGui.QPushButton(self.frame) self.buttonNew.setObjectName("buttonNew") self.ctxbuttonsLayout.addWidget(self.buttonNew) self.buttonEditCtx = QtGui.QPushButton(self.frame) self.buttonEditCtx.setObjectName("buttonEditCtx") self.ctxbuttonsLayout.addWidget(self.buttonEditCtx) self.buttonDelCtx = QtGui.QPushButton(self.frame) self.buttonDelCtx.setObjectName("buttonDelCtx") self.ctxbuttonsLayout.addWidget(self.buttonDelCtx) self.verticalLayout_3.addLayout(self.horizontalLayout_4) self.verticalLayout_3.addLayout(self.ctxbuttonsLayout) self.formLayout = QtGui.QFormLayout() #self.formLayout.setContentsMargins(-1, 4, -1, -1) self.formLayout.setObjectName("formLayout") self.infoLabel0_1 = QtGui.QLabel(self.frame) self.infoLabel0_1.setObjectName("infoLabel0_1") self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.infoLabel0_1) self.infoLabel0_1.hide() self.infoLabel1_1 = QtGui.QLabel(self.frame) self.infoLabel1_1.setObjectName("Author") self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.infoLabel1_1) self.infoLabel1_1.hide() self.infoLabel1_2 = QtGui.QLabel(self.frame) self.infoLabel1_2.setObjectName("infoLabel1_2") self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.infoLabel1_2) self.infoLabel1_2.hide() self.infoLabel2_1 = QtGui.QLabel(self.frame) self.infoLabel2_1.setObjectName("Reason") self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.infoLabel2_1) self.infoLabel2_1.hide() self.infoLabel2_2 = QtGui.QLabel(self.frame) self.infoLabel2_2.setObjectName("infoLabel2_2") self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.infoLabel2_2) self.infoLabel2_2.hide() self.infoLabel3_1 = QtGui.QLabel(self.frame) self.infoLabel3_1.setObjectName("Description") self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.infoLabel3_1) self.infoLabel3_1.hide() self.infoLabel3_2 = QtGui.QLabel(self.frame) self.infoLabel3_2.setObjectName("infoLabel3_2") self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.infoLabel3_2) self.infoLabel3_2.hide() self.infoLabel4_1 = QtGui.QLabel(self.frame) self.infoLabel4_1.setObjectName("Snapshots") self.formLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.infoLabel4_1) self.infoLabel4_1.hide() self.verticalLayout_3.addLayout(self.formLayout) self.listWidget = QtGui.QListWidget(self.frame) self.listWidget.setObjectName("listWidget") self.verticalLayout_3.addWidget(self.listWidget) self.verticalLayout_2.addWidget(self.frame) self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.buttonTake = QtGui.QPushButton(Form) self.buttonTake.setObjectName("buttonTake") self.horizontalLayout_2.addWidget(self.buttonTake) self.buttonTake.hide() self.buttonImport = QtGui.QPushButton(Form) self.buttonImport.setObjectName("buttonImport") self.horizontalLayout_2.addWidget(self.buttonImport) self.buttonImport.hide() self.verticalLayout_2.addLayout(self.horizontalLayout_2) #self.mainLayout.addLayout(self.verticalLayout_2) self.leftWidget = QtGui.QWidget() self.leftWidget.setLayout(self.verticalLayout_2) self.splitter.addWidget(self.leftWidget) #################### End of Left Panel #################### Right Panel 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.buttonEditSnap = QtGui.QPushButton(Form) self.buttonEditSnap.setObjectName("buttonEditSnap") self.horizontalLayout_5.addWidget(self.buttonEditSnap) self.buttonEditSnap.hide() 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.setMinimumWidth(400) self.frame_2.setObjectName("frame_2") 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.taurusForm = TaurusForm(self.frame_2) self.taurusForm.setObjectName("taurusForm") self.taurusForm.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.buttonExport = QtGui.QPushButton(Form) self.buttonExport.setObjectName("buttonExport") self.horizontalLayout.addWidget(self.buttonExport) self.buttonExport.hide() self.buttonLoad = QtGui.QPushButton(Form) self.buttonLoad.setObjectName("buttonLoad") self.horizontalLayout.addWidget(self.buttonLoad) self.buttonLoad.hide() self.buttonDelSnap = QtGui.QPushButton(Form) self.buttonDelSnap.setObjectName("buttonDelSnap") self.horizontalLayout.addWidget(self.buttonDelSnap) self.buttonDelSnap.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)) icon_close = QtGui.QIcon(":/actions/process-stop.svg") self.buttonClose.setIcon(icon_close) self.horizontalLayout.addWidget(self.buttonClose) self.verticalLayout.addLayout(self.horizontalLayout) #self.mainLayout.addLayout(self.verticalLayout) self.rightWidget = QtGui.QWidget() self.rightWidget.setLayout(self.verticalLayout) self.splitter.addWidget(self.rightWidget) ##################### End of Right Panel self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8)) self.infoLabel0_1.setText(QtGui.QApplication.translate("Form", "Attribute", None, QtGui.QApplication.UnicodeUTF8))
class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") self._Form=Form self.font=QtGui.QFont() self.font.setBold(True) self.gridLayout_2 = QtGui.QGridLayout(Form) self.gridLayout_2.setObjectName("gridLayout_2") self.gridLayout = QtGui.QGridLayout() self.gridLayout.setObjectName("gridLayout") self.chooseLabel=Qt.QLabel() self.chooseLabel.setObjectName("chooseLabel") self.chooseLabel.setFont(self.font) self.chooseLabel.setAlignment(QtCore.Qt.AlignCenter); self.gridLayout.addWidget(self.chooseLabel, 0, 0, 1, 1) self.tac=attributeChooser() self.tac.setObjectName("taurusAttributeChooser") self.gridLayout.addWidget(self.tac, 1, 0, 6, 1) self.selectedLabel=Qt.QLabel() self.selectedLabel.setObjectName("selectedLabel") self.selectedLabel.setFont(self.font) self.selectedLabel.setAlignment(QtCore.Qt.AlignCenter); self.selectedLabel.hide() self.gridLayout.addWidget(self.selectedLabel, 0, 1, 1, 6) self.tf=TaurusForm() self.tf.setWithButtons(False) self.tf.setObjectName("taurusForm") self.tf.hide() self.gridLayout.addWidget(self.tf, 1, 1, 1, 6) self.label=Qt.QLabel() self.label.setObjectName("label") self.label.setFont(self.font) self.label.setAlignment(QtCore.Qt.AlignCenter); self.gridLayout.addWidget(self.label, 1, 1, 1, 6) spacerItem = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.gridLayout.addItem(spacerItem, 1, 1, 1, 1) self.modepLabel = QtGui.QLabel(Form) self.modepLabel.setObjectName("modepLabel") self.modepLabel.setText('Period [s]:') self.gridLayout.addWidget(self.modepLabel, 2, 1, 1, 1) self.modepLineEdit = QtGui.QLineEdit(Form) self.modepLineEdit.setObjectName("modepLineEdit") self.modepLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 1, Form)) self.modepLineEdit.setMaxLength(7) self.modepLineEdit.setMaximumWidth(60) self.modepLineEdit.setText('60.0') self.gridLayout.addWidget(self.modepLineEdit, 2, 2, 1, 1) self.modeaLabel = QtGui.QLabel(Form) self.modeaLabel.setObjectName("modeaLabel") self.modeaLabel.setText('Absolute Period [s]:') self.gridLayout.addWidget(self.modeaLabel, 3, 1, 1, 1) self.modeaLineEdit = QtGui.QLineEdit(Form) self.modeaLineEdit.setObjectName("modeaLineEdit") self.modeaLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 1, Form)) self.modeaLineEdit.setMaxLength(7) self.modeaLineEdit.setMaximumWidth(60) self.modeaLineEdit.setText('15.0') self.gridLayout.addWidget(self.modeaLineEdit, 3, 2, 1, 1) self.modeaLowerLimitLabel = QtGui.QLabel(Form) self.modeaLowerLimitLabel.setObjectName("modeaLowerLimitLabel") self.modeaLowerLimitLabel.setText('Lower Limit (decr.):') self.gridLayout.addWidget(self.modeaLowerLimitLabel, 3, 3, 1, 1) self.modeaLowerLimitLineEdit = QtGui.QLineEdit(Form) self.modeaLowerLimitLineEdit.setObjectName("modeaLowerLimitLineEdit") self.modeaLowerLimitLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 2, Form)) self.modeaLowerLimitLineEdit.setMaxLength(7) self.modeaLowerLimitLineEdit.setMaximumWidth(60) self.gridLayout.addWidget(self.modeaLowerLimitLineEdit, 3, 4, 1, 1) self.modeaUpperLimitLabel = QtGui.QLabel(Form) self.modeaUpperLimitLabel.setObjectName("modeaUpperLimitLabel") self.modeaUpperLimitLabel.setText('Upper Limit (incr.):') self.gridLayout.addWidget(self.modeaUpperLimitLabel, 3, 5, 1, 1) self.modeaUpperLimitLineEdit = QtGui.QLineEdit(Form) self.modeaUpperLimitLineEdit.setObjectName("modeaUpperLimitLineEdit") self.modeaUpperLimitLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 2, Form)) self.modeaUpperLimitLineEdit.setMaxLength(7) self.modeaUpperLimitLineEdit.setMaximumWidth(60) self.gridLayout.addWidget(self.modeaUpperLimitLineEdit, 3, 6, 1, 1) self.moderLabel = QtGui.QLabel(Form) self.moderLabel.setObjectName("moderLabel") self.moderLabel.setText('Relative Period [s]:') self.gridLayout.addWidget(self.moderLabel, 4, 1, 1, 1) self.moderLineEdit = QtGui.QLineEdit(Form) self.moderLineEdit.setObjectName("moderLineEdit") self.moderLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 1, Form)) self.moderLineEdit.setMaxLength(7) self.moderLineEdit.setMaximumWidth(60) self.moderLineEdit.setText('15.0') self.gridLayout.addWidget(self.moderLineEdit, 4, 2, 1, 1) self.moderLowerLimitPercentLabel = QtGui.QLabel(Form) self.moderLowerLimitPercentLabel.setObjectName("moderLowerLimitPercentLabel") self.moderLowerLimitPercentLabel.setText('Lower % Limit (decr.):') self.gridLayout.addWidget(self.moderLowerLimitPercentLabel, 4, 3, 1, 1) self.moderLowerLimitPercentLineEdit = QtGui.QLineEdit(Form) self.moderLowerLimitPercentLineEdit.setObjectName("moderLowerLimitPercentLineEdit") self.moderLowerLimitPercentLineEdit.setValidator(QtGui.QDoubleValidator(0, 1, 2, Form)) self.moderLowerLimitPercentLineEdit.setMaxLength(7) self.moderLowerLimitPercentLineEdit.setMaximumWidth(60) self.gridLayout.addWidget(self.moderLowerLimitPercentLineEdit, 4, 4, 1, 1) self.moderUpperLimitPercentLabel = QtGui.QLabel(Form) self.moderUpperLimitPercentLabel.setObjectName("moderUpperLimitPercentLabel") self.moderUpperLimitPercentLabel.setText('Upper % Limit (incr.):') self.gridLayout.addWidget(self.moderUpperLimitPercentLabel, 4, 5, 1, 1) self.moderUpperLimitPercentLineEdit = QtGui.QLineEdit(Form) self.moderUpperLimitPercentLineEdit.setObjectName("moderUpperLimitPercentLineEdit") self.moderUpperLimitPercentLineEdit.setValidator(Qt.QDoubleValidator(0, 1, 2, Form)) self.moderUpperLimitPercentLineEdit.setMaxLength(7) self.moderUpperLimitPercentLineEdit.setMaximumWidth(60) self.gridLayout.addWidget(self.moderUpperLimitPercentLineEdit, 4, 6, 1, 1) self.gridButtonLayout = QtGui.QGridLayout() self.gridButtonLayout.setObjectName("gridButtonLayout") spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.gridButtonLayout.addItem(spacerItem, 0, 1, 1, 1) self.pushButtonStart = QtGui.QPushButton(Form) self.pushButtonStart.setObjectName("pushButtonStart") self.pushButtonStart.setEnabled(False) self.gridButtonLayout.addWidget(self.pushButtonStart, 0, 2, 1, 1) self.pushButtonStop = QtGui.QPushButton(Form) self.pushButtonStop.setObjectName("pushButtonStop") self.pushButtonStop.setEnabled(False) self.gridButtonLayout.addWidget(self.pushButtonStop, 0, 3, 1, 1) self.pushButtonCancel = QtGui.QPushButton(Form) self.pushButtonCancel.setObjectName("pushButtonCancel") self.gridButtonLayout.addWidget(self.pushButtonCancel, 0, 4, 1, 1) self.gridLayout.addLayout(self.gridButtonLayout, 5, 1, 1, 6) self.gridLayout_2.addLayout(self.gridLayout, 1, 0, 1, 1) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): Form.setWindowTitle(QtGui.QApplication.translate("Form", "Archiving Widget", None, QtGui.QApplication.UnicodeUTF8)) self.pushButtonStart.setText(QtGui.QApplication.translate("Form", "Start Archiving", None, QtGui.QApplication.UnicodeUTF8)) self.pushButtonStop.setText(QtGui.QApplication.translate("Form", "Stop", None, QtGui.QApplication.UnicodeUTF8)) self.pushButtonCancel.setText(QtGui.QApplication.translate("Form", "Close", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(QtGui.QApplication.translate("Form", "Nothing to display", None, QtGui.QApplication.UnicodeUTF8)) self.selectedLabel.setText(QtGui.QApplication.translate("Form", "Press start to start archiving selected attributes:", None, QtGui.QApplication.UnicodeUTF8)) self.chooseLabel.setText(QtGui.QApplication.translate("Form", "Choose attributes to archive and hit apply to move attributes to selection", None, QtGui.QApplication.UnicodeUTF8)) self.tf.connect(self.tac, Qt.SIGNAL("UpdateAttrs"), self.onUpdate) QtCore.QObject.connect(self.pushButtonStart, Qt.SIGNAL("clicked()"), self.onStart) QtCore.QObject.connect(self.pushButtonStop, Qt.SIGNAL("clicked()"), self.onStop) QtCore.QObject.connect(self.pushButtonCancel, Qt.SIGNAL("clicked()"), self.onCancel) QtCore.QObject.connect(self.modepLineEdit, Qt.SIGNAL('textChanged(const QString &)'), self.modepTextChanged) QtCore.QObject.connect(self.modeaLineEdit, Qt.SIGNAL('textChanged(const QString &)'), self.modeaTextChanged) QtCore.QObject.connect(self.moderLineEdit, Qt.SIGNAL('textChanged(const QString &)'), self.moderTextChanged) #QtCore.QObject.connect(self.moderUpperLimitPercentLineEdit, Qt.SIGNAL('editingFinished()'), self.moderUpperLimitPercentTextChanged) #QtCore.QObject.connect(self.moderLowerLimitPercentLineEdit, Qt.SIGNAL('editingFinished()'), self.moderLowerLimitPercentTextChanged) #QtCore.QObject.connect(self.modeaUpperLimitLineEdit, Qt.SIGNAL('editingFinished()'), self.modeaUpperLimitTextChanged) #QtCore.QObject.connect(self.modeaLowerLimitLineEdit, Qt.SIGNAL('editingFinished()'), self.modeaLowerLimitTextChanged) def modepTextChanged(self): if self.modepLineEdit.text(): if (float(self.modepLineEdit.text()) < 1 or float(self.modepLineEdit.text()) > 14400): Qt.QMessageBox.critical(self._Form,'Error','Value ranges between 1 and 14400', QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole) if float(self.modepLineEdit.text()) > 14400: self.modepLineEdit.setText('14400') else: self.modepLineEdit.setText('1') else: Qt.QMessageBox.critical(self._Form,'Error','Value ranges between 1 and 14400', QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole) self.modepLineEdit.setText('1') def modeaTextChanged(self): if self.modeaLineEdit.text(): if (float(self.modeaLineEdit.text()) > float(self.modepLineEdit.text())): Qt.QMessageBox.critical(self._Form,'Error','Value cannot be higher than '+self.modepLineEdit.text(), QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole) self.modeaLineEdit.setText('0') def moderTextChanged(self): if self.moderLineEdit.text(): if (float(self.moderLineEdit.text()) > float(self.modepLineEdit.text())): Qt.QMessageBox.critical(self._Form,'Error','Value cannot be higher than '+self.modepLineEdit.text(), QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole) self.moderLineEdit.setText('0') def validate(self, modep, modea, moder): if (modep < modea or modep < moder): Qt.QMessageBox.critical(self._Form,'Error','Period value has to be higher than the others', QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole) self.modepLineEdit.setText(str(10*max(int(self.moderLineEdit.text()), int(self.modeaLineEdit.text())))) return False return True def floatValidation(self, line): val = line.text() try: float(val) return True except: Qt.QMessageBox.critical(self._Form,'Error in '+str(line.objectName()),'Wrong value !\nSetting value to 0!', QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole) line.setText('0') return False def onStart(self): self.floatValidation(self.moderUpperLimitPercentLineEdit) self.floatValidation(self.moderLowerLimitPercentLineEdit) self.floatValidation(self.modeaUpperLimitLineEdit) self.floatValidation(self.modeaLowerLimitLineEdit) try: self.modep=int(1000*self.modepLineEdit.text()) self.modea=(int(1000*self.modeaLineEdit.text()) if self.modeaLineEdit.text() else None) self.modeaLowerLimit=(float(self.modeaLowerLimitLineEdit.text()) if self.modeaLowerLimitLineEdit.text() else None) self.modeaUpperLimit=(float(self.modeaUpperLimitLineEdit.text()) if self.modeaUpperLimitLineEdit.text() else None) self.moder=(int(1000*self.moderLineEdit.text()) if self.moderLineEdit.text() else None) self.moderLowerLimit=(float(self.moderLowerLimitPercentLineEdit.text()) if self.moderLowerLimitPercentLineEdit.text() else None) self.moderUpperLimit=(float(self.moderUpperLimitPercentLineEdit.text()) if self.moderUpperLimitPercentLineEdit.text() else None) if self.validate(self.modep, self.modea, self.moder): reply=Qt.QMessageBox.question(self._Form,"Warning","Do you want to start archiving selected attributes?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) if reply == QtGui.QMessageBox.Yes: command={'MODE_P':[self.modep]} if (self.modea and self.modeaUpperLimit and self.modeaLowerLimit): command['MODE_A']=[self.modea, self.modeaUpperLimit, self.modeaLowerLimit] if (self.moder and self.moderUpperLimit and self.moderLowerLimit): command['MODE_R']=[self.moder, self.moderUpperLimit, self.moderLowerLimit] attrs=[a for a in self.tf.getModel()] cmd=self.tac.tdb.check_modes('tdb', command) toStop=[a for a in attrs if a in self.tac.beingArchived] try: if toStop: self.tac.tdb.api.start_archiving(attrs, cmd, kill=True) else: self.tac.tdb.api.start_archiving(attrs, cmd) except: Qt.QMessageBox.critical(self._Form,"Error",'Cannot start archiving process.\nCheck the state of archiving managers.', QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole) print(traceback.format_exc()) self.tac.beingArchived=[a.lower() for a in self.tac.tdb if self.tac.tdb.is_attribute_archived(a.lower())] #update archived list self.onUpdate(attrs) self.tac.setNewDevName() except: print(traceback.format_exc()) def onStop(self): toStop=[att.lower() for att in self.tf.getModel() if att.lower() in self.tac.beingArchived] reply=Qt.QMessageBox.question(self._Form,"Warning","Do you want to stop archiving "+str(len(toStop))+" attributes?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) if reply == QtGui.QMessageBox.Yes: self.tac.tdb.api.stop_archiving(toStop) self.tac.beingArchived=[a.lower() for a in self.tac.tdb if self.tac.tdb.is_attribute_archived(a.lower())] #update archived list self.pushButtonStop.setEnabled(False) self.pushButtonStop.setText('Stop') self.tac.setNewDevName() self.clearParams() def onUpdate(self, attrs): self.clearParams() if not attrs: self.tf.hide() self.label.show() self.selectedLabel.hide() self.pushButtonStart.setEnabled(False) self.pushButtonStop.setEnabled(False) self.pushButtonStop.setText('Stop') else: self.label.hide() self.selectedLabel.show() self.tf.show() self.tf.setModel(attrs) for i in range(len(attrs)): item=self.tf.getItemByIndex(i) if item.getModel().lower() in self.tac.beingArchived: item.setExtraWidgetClass(historyButton) historyButton().setModel(item.getModel()) self.pushButtonStart.setEnabled(True) toStop=[att.lower() for att in attrs if att.lower() in self.tac.beingArchived] if toStop: self.pushButtonStop.setEnabled(True) self.pushButtonStop.setText('Stop ('+str(len(toStop))+')') modes=self.tac.tdb.get(toStop[0]).modes if 'MODE_P' in modes.keys(): self.modepLineEdit.setText(str(int(modes['MODE_P'][0]/1000))) if 'MODE_R' in modes.keys(): if len(modes['MODE_R']) == 3: self.moderLineEdit.setText(str(int(modes['MODE_R'][0]/1000))) self.moderLowerLimitPercentLineEdit.setText(str(float(modes['MODE_R'][1]))) self.moderUpperLimitPercentLineEdit.setText(str(float(modes['MODE_R'][2]))) if 'MODE_A' in modes.keys(): if len(modes['MODE_A']) == 3: self.modeaLineEdit.setText(str(int(modes['MODE_A'][0]/1000))) self.modeaLowerLimitLineEdit.setText(str(int(modes['MODE_A'][1]))) self.modeaUpperLimitLineEdit.setText(str(int(modes['MODE_A'][2]))) else: self.pushButtonStop.setEnabled(False) self.pushButtonStop.setText('Stop') def clearParams(self): self.modepLineEdit.setText('60') self.moderLineEdit.setText('') self.moderLowerLimitPercentLineEdit.setText('') self.moderUpperLimitPercentLineEdit.setText('') self.modeaLineEdit.setText('') self.modeaLowerLimitLineEdit.setText('') self.modeaUpperLimitLineEdit.setText('') def onCancel(self): self._Form.close()
class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") self._Form = Form self.font = QtGui.QFont() self.font.setBold(True) self.gridLayout_2 = QtGui.QGridLayout(Form) self.gridLayout_2.setObjectName("gridLayout_2") self.gridLayout = QtGui.QGridLayout() self.gridLayout.setObjectName("gridLayout") self.chooseLabel = Qt.QLabel() self.chooseLabel.setObjectName("chooseLabel") self.chooseLabel.setFont(self.font) self.chooseLabel.setAlignment(QtCore.Qt.AlignCenter) self.gridLayout.addWidget(self.chooseLabel, 0, 0, 1, 1) self.tac = attributeChooser() self.tac.setObjectName("taurusAttributeChooser") self.gridLayout.addWidget(self.tac, 1, 0, 6, 1) self.selectedLabel = Qt.QLabel() self.selectedLabel.setObjectName("selectedLabel") self.selectedLabel.setFont(self.font) self.selectedLabel.setAlignment(QtCore.Qt.AlignCenter) self.selectedLabel.hide() self.gridLayout.addWidget(self.selectedLabel, 0, 1, 1, 6) self.tf = TaurusForm() self.tf.setWithButtons(False) self.tf.setObjectName("taurusForm") self.tf.hide() self.gridLayout.addWidget(self.tf, 1, 1, 1, 6) self.label = Qt.QLabel() self.label.setObjectName("label") self.label.setFont(self.font) self.label.setAlignment(QtCore.Qt.AlignCenter) self.gridLayout.addWidget(self.label, 1, 1, 1, 6) spacerItem = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.gridLayout.addItem(spacerItem, 1, 1, 1, 1) self.modepLabel = QtGui.QLabel(Form) self.modepLabel.setObjectName("modepLabel") self.modepLabel.setText('Period [s]:') self.gridLayout.addWidget(self.modepLabel, 2, 1, 1, 1) self.modepLineEdit = QtGui.QLineEdit(Form) self.modepLineEdit.setObjectName("modepLineEdit") self.modepLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 1, Form)) self.modepLineEdit.setMaxLength(7) self.modepLineEdit.setMaximumWidth(60) self.modepLineEdit.setText('60.0') self.gridLayout.addWidget(self.modepLineEdit, 2, 2, 1, 1) self.modeaLabel = QtGui.QLabel(Form) self.modeaLabel.setObjectName("modeaLabel") self.modeaLabel.setText('Absolute Period [s]:') self.gridLayout.addWidget(self.modeaLabel, 3, 1, 1, 1) self.modeaLineEdit = QtGui.QLineEdit(Form) self.modeaLineEdit.setObjectName("modeaLineEdit") self.modeaLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 1, Form)) self.modeaLineEdit.setMaxLength(7) self.modeaLineEdit.setMaximumWidth(60) self.modeaLineEdit.setText('15.0') self.gridLayout.addWidget(self.modeaLineEdit, 3, 2, 1, 1) self.modeaLowerLimitLabel = QtGui.QLabel(Form) self.modeaLowerLimitLabel.setObjectName("modeaLowerLimitLabel") self.modeaLowerLimitLabel.setText('Lower Limit (decr.):') self.gridLayout.addWidget(self.modeaLowerLimitLabel, 3, 3, 1, 1) self.modeaLowerLimitLineEdit = QtGui.QLineEdit(Form) self.modeaLowerLimitLineEdit.setObjectName("modeaLowerLimitLineEdit") self.modeaLowerLimitLineEdit.setValidator( Qt.QDoubleValidator(1, 14400, 2, Form)) self.modeaLowerLimitLineEdit.setMaxLength(7) self.modeaLowerLimitLineEdit.setMaximumWidth(60) self.gridLayout.addWidget(self.modeaLowerLimitLineEdit, 3, 4, 1, 1) self.modeaUpperLimitLabel = QtGui.QLabel(Form) self.modeaUpperLimitLabel.setObjectName("modeaUpperLimitLabel") self.modeaUpperLimitLabel.setText('Upper Limit (incr.):') self.gridLayout.addWidget(self.modeaUpperLimitLabel, 3, 5, 1, 1) self.modeaUpperLimitLineEdit = QtGui.QLineEdit(Form) self.modeaUpperLimitLineEdit.setObjectName("modeaUpperLimitLineEdit") self.modeaUpperLimitLineEdit.setValidator( Qt.QDoubleValidator(1, 14400, 2, Form)) self.modeaUpperLimitLineEdit.setMaxLength(7) self.modeaUpperLimitLineEdit.setMaximumWidth(60) self.gridLayout.addWidget(self.modeaUpperLimitLineEdit, 3, 6, 1, 1) self.moderLabel = QtGui.QLabel(Form) self.moderLabel.setObjectName("moderLabel") self.moderLabel.setText('Relative Period [s]:') self.gridLayout.addWidget(self.moderLabel, 4, 1, 1, 1) self.moderLineEdit = QtGui.QLineEdit(Form) self.moderLineEdit.setObjectName("moderLineEdit") self.moderLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 1, Form)) self.moderLineEdit.setMaxLength(7) self.moderLineEdit.setMaximumWidth(60) self.moderLineEdit.setText('15.0') self.gridLayout.addWidget(self.moderLineEdit, 4, 2, 1, 1) self.moderLowerLimitPercentLabel = QtGui.QLabel(Form) self.moderLowerLimitPercentLabel.setObjectName( "moderLowerLimitPercentLabel") self.moderLowerLimitPercentLabel.setText('Lower % Limit (decr.):') self.gridLayout.addWidget(self.moderLowerLimitPercentLabel, 4, 3, 1, 1) self.moderLowerLimitPercentLineEdit = QtGui.QLineEdit(Form) self.moderLowerLimitPercentLineEdit.setObjectName( "moderLowerLimitPercentLineEdit") self.moderLowerLimitPercentLineEdit.setValidator( QtGui.QDoubleValidator(0, 1, 2, Form)) self.moderLowerLimitPercentLineEdit.setMaxLength(7) self.moderLowerLimitPercentLineEdit.setMaximumWidth(60) self.gridLayout.addWidget(self.moderLowerLimitPercentLineEdit, 4, 4, 1, 1) self.moderUpperLimitPercentLabel = QtGui.QLabel(Form) self.moderUpperLimitPercentLabel.setObjectName( "moderUpperLimitPercentLabel") self.moderUpperLimitPercentLabel.setText('Upper % Limit (incr.):') self.gridLayout.addWidget(self.moderUpperLimitPercentLabel, 4, 5, 1, 1) self.moderUpperLimitPercentLineEdit = QtGui.QLineEdit(Form) self.moderUpperLimitPercentLineEdit.setObjectName( "moderUpperLimitPercentLineEdit") self.moderUpperLimitPercentLineEdit.setValidator( Qt.QDoubleValidator(0, 1, 2, Form)) self.moderUpperLimitPercentLineEdit.setMaxLength(7) self.moderUpperLimitPercentLineEdit.setMaximumWidth(60) self.gridLayout.addWidget(self.moderUpperLimitPercentLineEdit, 4, 6, 1, 1) self.gridButtonLayout = QtGui.QGridLayout() self.gridButtonLayout.setObjectName("gridButtonLayout") spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.gridButtonLayout.addItem(spacerItem, 0, 1, 1, 1) self.pushButtonStart = QtGui.QPushButton(Form) self.pushButtonStart.setObjectName("pushButtonStart") self.pushButtonStart.setEnabled(False) self.gridButtonLayout.addWidget(self.pushButtonStart, 0, 2, 1, 1) self.pushButtonStop = QtGui.QPushButton(Form) self.pushButtonStop.setObjectName("pushButtonStop") self.pushButtonStop.setEnabled(False) self.gridButtonLayout.addWidget(self.pushButtonStop, 0, 3, 1, 1) self.pushButtonCancel = QtGui.QPushButton(Form) self.pushButtonCancel.setObjectName("pushButtonCancel") self.gridButtonLayout.addWidget(self.pushButtonCancel, 0, 4, 1, 1) self.gridLayout.addLayout(self.gridButtonLayout, 5, 1, 1, 6) self.gridLayout_2.addLayout(self.gridLayout, 1, 0, 1, 1) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): Form.setWindowTitle( QtGui.QApplication.translate("Form", "Archiving Widget", None, QtGui.QApplication.UnicodeUTF8)) self.pushButtonStart.setText( QtGui.QApplication.translate("Form", "Start Archiving", None, QtGui.QApplication.UnicodeUTF8)) self.pushButtonStop.setText( QtGui.QApplication.translate("Form", "Stop", None, QtGui.QApplication.UnicodeUTF8)) self.pushButtonCancel.setText( QtGui.QApplication.translate("Form", "Close", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText( QtGui.QApplication.translate("Form", "Nothing to display", None, QtGui.QApplication.UnicodeUTF8)) self.selectedLabel.setText( QtGui.QApplication.translate( "Form", "Press start to start archiving selected attributes:", None, QtGui.QApplication.UnicodeUTF8)) self.chooseLabel.setText( QtGui.QApplication.translate( "Form", "Choose attributes to archive and hit apply to move attributes to selection", None, QtGui.QApplication.UnicodeUTF8)) self.tf.connect(self.tac, Qt.SIGNAL("UpdateAttrs"), self.onUpdate) QtCore.QObject.connect(self.pushButtonStart, Qt.SIGNAL("clicked()"), self.onStart) QtCore.QObject.connect(self.pushButtonStop, Qt.SIGNAL("clicked()"), self.onStop) QtCore.QObject.connect(self.pushButtonCancel, Qt.SIGNAL("clicked()"), self.onCancel) QtCore.QObject.connect(self.modepLineEdit, Qt.SIGNAL('textChanged(const QString &)'), self.modepTextChanged) QtCore.QObject.connect(self.modeaLineEdit, Qt.SIGNAL('textChanged(const QString &)'), self.modeaTextChanged) QtCore.QObject.connect(self.moderLineEdit, Qt.SIGNAL('textChanged(const QString &)'), self.moderTextChanged) #QtCore.QObject.connect(self.moderUpperLimitPercentLineEdit, Qt.SIGNAL('editingFinished()'), self.moderUpperLimitPercentTextChanged) #QtCore.QObject.connect(self.moderLowerLimitPercentLineEdit, Qt.SIGNAL('editingFinished()'), self.moderLowerLimitPercentTextChanged) #QtCore.QObject.connect(self.modeaUpperLimitLineEdit, Qt.SIGNAL('editingFinished()'), self.modeaUpperLimitTextChanged) #QtCore.QObject.connect(self.modeaLowerLimitLineEdit, Qt.SIGNAL('editingFinished()'), self.modeaLowerLimitTextChanged) def modepTextChanged(self): if self.modepLineEdit.text(): if (float(self.modepLineEdit.text()) < 1 or float(self.modepLineEdit.text()) > 14400): Qt.QMessageBox.critical(self._Form, 'Error', 'Value ranges between 1 and 14400', QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole) if float(self.modepLineEdit.text()) > 14400: self.modepLineEdit.setText('14400') else: self.modepLineEdit.setText('1') else: Qt.QMessageBox.critical(self._Form, 'Error', 'Value ranges between 1 and 14400', QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole) self.modepLineEdit.setText('1') def modeaTextChanged(self): if self.modeaLineEdit.text(): if (float(self.modeaLineEdit.text()) > float( self.modepLineEdit.text())): Qt.QMessageBox.critical( self._Form, 'Error', 'Value cannot be higher than ' + self.modepLineEdit.text(), QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole) self.modeaLineEdit.setText('0') def moderTextChanged(self): if self.moderLineEdit.text(): if (float(self.moderLineEdit.text()) > float( self.modepLineEdit.text())): Qt.QMessageBox.critical( self._Form, 'Error', 'Value cannot be higher than ' + self.modepLineEdit.text(), QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole) self.moderLineEdit.setText('0') def validate(self, modep, modea, moder): if (modep < modea or modep < moder): Qt.QMessageBox.critical( self._Form, 'Error', 'Period value has to be higher than the others', QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole) self.modepLineEdit.setText( str(10 * max(int(self.moderLineEdit.text()), int(self.modeaLineEdit.text())))) return False return True def floatValidation(self, line): val = line.text() try: float(val) return True except: Qt.QMessageBox.critical(self._Form, 'Error in ' + str(line.objectName()), 'Wrong value !\nSetting value to 0!', QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole) line.setText('0') return False def onStart(self): self.floatValidation(self.moderUpperLimitPercentLineEdit) self.floatValidation(self.moderLowerLimitPercentLineEdit) self.floatValidation(self.modeaUpperLimitLineEdit) self.floatValidation(self.modeaLowerLimitLineEdit) try: self.modep = int(1000 * self.modepLineEdit.text()) self.modea = (int(1000 * self.modeaLineEdit.text()) if self.modeaLineEdit.text() else None) self.modeaLowerLimit = (float(self.modeaLowerLimitLineEdit.text()) if self.modeaLowerLimitLineEdit.text() else None) self.modeaUpperLimit = (float(self.modeaUpperLimitLineEdit.text()) if self.modeaUpperLimitLineEdit.text() else None) self.moder = (int(1000 * self.moderLineEdit.text()) if self.moderLineEdit.text() else None) self.moderLowerLimit = ( float(self.moderLowerLimitPercentLineEdit.text()) if self.moderLowerLimitPercentLineEdit.text() else None) self.moderUpperLimit = ( float(self.moderUpperLimitPercentLineEdit.text()) if self.moderUpperLimitPercentLineEdit.text() else None) if self.validate(self.modep, self.modea, self.moder): reply = Qt.QMessageBox.question( self._Form, "Warning", "Do you want to start archiving selected attributes?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) if reply == QtGui.QMessageBox.Yes: command = {'MODE_P': [self.modep]} if (self.modea and self.modeaUpperLimit and self.modeaLowerLimit): command['MODE_A'] = [ self.modea, self.modeaUpperLimit, self.modeaLowerLimit ] if (self.moder and self.moderUpperLimit and self.moderLowerLimit): command['MODE_R'] = [ self.moder, self.moderUpperLimit, self.moderLowerLimit ] attrs = [a for a in self.tf.getModel()] cmd = self.tac.tdb.check_modes('tdb', command) toStop = [a for a in attrs if a in self.tac.beingArchived] try: if toStop: self.tac.tdb.api.start_archiving(attrs, cmd, kill=True) else: self.tac.tdb.api.start_archiving(attrs, cmd) except: Qt.QMessageBox.critical( self._Form, "Error", 'Cannot start archiving process.\nCheck the state of archiving managers.', QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole) print(traceback.format_exc()) self.tac.beingArchived = [ a.lower() for a in self.tac.tdb if self.tac.tdb.is_attribute_archived(a.lower()) ] #update archived list self.onUpdate(attrs) self.tac.setNewDevName() except: print(traceback.format_exc()) def onStop(self): toStop = [ att.lower() for att in self.tf.getModel() if att.lower() in self.tac.beingArchived ] reply = Qt.QMessageBox.question( self._Form, "Warning", "Do you want to stop archiving " + str(len(toStop)) + " attributes?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) if reply == QtGui.QMessageBox.Yes: self.tac.tdb.api.stop_archiving(toStop) self.tac.beingArchived = [ a.lower() for a in self.tac.tdb if self.tac.tdb.is_attribute_archived(a.lower()) ] #update archived list self.pushButtonStop.setEnabled(False) self.pushButtonStop.setText('Stop') self.tac.setNewDevName() self.clearParams() def onUpdate(self, attrs): self.clearParams() if not attrs: self.tf.hide() self.label.show() self.selectedLabel.hide() self.pushButtonStart.setEnabled(False) self.pushButtonStop.setEnabled(False) self.pushButtonStop.setText('Stop') else: self.label.hide() self.selectedLabel.show() self.tf.show() self.tf.setModel(attrs) for i in range(len(attrs)): item = self.tf.getItemByIndex(i) if item.getModel().lower() in self.tac.beingArchived: item.setExtraWidgetClass(historyButton) historyButton().setModel(item.getModel()) self.pushButtonStart.setEnabled(True) toStop = [ att.lower() for att in attrs if att.lower() in self.tac.beingArchived ] if toStop: self.pushButtonStop.setEnabled(True) self.pushButtonStop.setText('Stop (' + str(len(toStop)) + ')') modes = self.tac.tdb.get(toStop[0]).modes if 'MODE_P' in modes.keys(): self.modepLineEdit.setText( str(int(modes['MODE_P'][0] / 1000))) if 'MODE_R' in modes.keys(): if len(modes['MODE_R']) == 3: self.moderLineEdit.setText( str(int(modes['MODE_R'][0] / 1000))) self.moderLowerLimitPercentLineEdit.setText( str(float(modes['MODE_R'][1]))) self.moderUpperLimitPercentLineEdit.setText( str(float(modes['MODE_R'][2]))) if 'MODE_A' in modes.keys(): if len(modes['MODE_A']) == 3: self.modeaLineEdit.setText( str(int(modes['MODE_A'][0] / 1000))) self.modeaLowerLimitLineEdit.setText( str(int(modes['MODE_A'][1]))) self.modeaUpperLimitLineEdit.setText( str(int(modes['MODE_A'][2]))) else: self.pushButtonStop.setEnabled(False) self.pushButtonStop.setText('Stop') def clearParams(self): self.modepLineEdit.setText('60') self.moderLineEdit.setText('') self.moderLowerLimitPercentLineEdit.setText('') self.moderUpperLimitPercentLineEdit.setText('') self.modeaLineEdit.setText('') self.modeaLowerLimitLineEdit.setText('') self.modeaUpperLimitLineEdit.setText('') def onCancel(self): self._Form.close()