def __init__(self, parent=None, options=None): qt.QWidget.__init__(self, parent) self.mainLayout = qt.QGridLayout(self) self.mainLayout.setMargin(0) self.mainLayout.setSpacing(2) self.buttonGroup = qt.QButtonGroup(self) self.buttonList = [] i = 0 if options is None: optionList = ['SCAN', 'MCA'] else: optionList = options actionList = ['ADD', 'REMOVE', 'REPLACE'] for option in optionList: row = optionList.index(option) for action in actionList: col = actionList.index(action) button = qt.QPushButton(self) button.setText(action + " " + option) self.mainLayout.addWidget(button, row, col) self.buttonGroup.addButton(button) self.buttonList.append(button) self.connect(self.buttonGroup, qt.SIGNAL('buttonClicked(QAbstractButton *)'), self.emitSignal)
def __init__(self, parent=None, name=None, fl=0, keys=(), params=()): if QTVERSION < '4.0.0': qt.QWidget.__init__(self, parent, name, fl) if name == None: self.setName("RadioField") #self.resize(166,607) self.setSizePolicy( qt.QSizePolicy(1, 1, 0, 0, self.sizePolicy().hasHeightForWidth())) self.setCaption(str("RadioField")) RadioFieldLayout = qt.QHBoxLayout(self, 11, 6, "RadioFieldLayout") else: qt.QWidget.__init__(self, parent) RadioFieldLayout = qt.QHBoxLayout(self) RadioFieldLayout.setMargin(11) RadioFieldLayout.setSpacing(6) self.RadioFieldBox = qt.QButtonGroup(self) if QTVERSION < '4.0.0': self.RadioFieldBox.setSizePolicy( qt.QSizePolicy( 1, 1, 0, 0, self.RadioFieldBox.sizePolicy().hasHeightForWidth())) self.RadioFieldBox.setTitle(str("")) self.RadioFieldBox.setColumnLayout(0, qt.Qt.Vertical) self.RadioFieldBox.layout().setSpacing(6) self.RadioFieldBox.layout().setMargin(11) RadioFieldBoxLayout = qt.QVBoxLayout(self.RadioFieldBox.layout()) RadioFieldBoxLayout.setAlignment(qt.Qt.AlignTop) Layout1 = qt.QVBoxLayout(None, 0, 6, "Layout1") self.dict = {} if type(keys) == TupleType: for key in keys: self.dict[key] = 1 else: self.dict[keys] = 1 self.RadioButton = [] i = 0 for text in params: self.RadioButton.append( qt.QRadioButton(self.RadioFieldBox, "RadioButton" + "%d" % i)) self.RadioButton[-1].setSizePolicy( qt.QSizePolicy( 1, 1, 0, 0, self.RadioButton[-1].sizePolicy().hasHeightForWidth())) self.RadioButton[-1].setText(str(text)) Layout1.addWidget(self.RadioButton[-1]) i = i + 1 RadioFieldBoxLayout.addLayout(Layout1) RadioFieldLayout.addWidget(self.RadioFieldBox) self.RadioButton[0].setChecked(1) self.connect(self.RadioFieldBox, qt.SIGNAL("clicked(int)"), self.setvalue)
def __init__(self, parent=None): qt.QWidget.__init__(self, parent) self.mainLayout = qt.QHBoxLayout(self) #self.mainLayout.setMargin(0) #self.mainLayout.setSpacing(0) self.buttonGroup = qt.QButtonGroup(self) i = 0 for text in [ "1D data is first dimension", "1D data is last dimension" ]: rButton = qt.QRadioButton(self) rButton.setText(text) self.mainLayout.addWidget(rButton) self.buttonGroup.addButton(rButton, i) i += 1 rButton.setChecked(True) self._stackIndex = -1 self.connect(self.buttonGroup, qt.SIGNAL('buttonPressed(QAbstractButton *)'), self._slot)
def configureFilter(self): msg = qt.QDialog() msgLayout = qt.QGridLayout() buttonLayout = qt.QHBoxLayout() inpThreshold = qt.QDoubleSpinBox() inpThreshold.setRange(0., 10.) inpThreshold.setSingleStep(.1) inpThreshold.setValue(2.0) inpThreshold.setToolTip('Increase width for broad spikes') inpWidth = qt.QSpinBox() inpWidth.setRange(1, 101) inpWidth.setSingleStep(2) inpWidth.setValue(self.width) inpWidth.setToolTip( 'Set low threshold for multiple spikes of different markedness') labelWidth = qt.QLabel('Width (must be odd)') labelThreshold = qt.QLabel('Threshold (multiple of deviation)') buttonOK = qt.QPushButton('Ok') buttonOK.clicked.connect(msg.accept) buttonCancel = qt.QPushButton('Cancel') buttonCancel.clicked.connect(msg.reject) allActiveBG = qt.QButtonGroup() buttonAll = qt.QCheckBox('Apply to All') buttonActive = qt.QCheckBox('Apply to Active') allActiveBG.addButton(buttonAll, 0) allActiveBG.addButton(buttonActive, 1) buttonLayout.addWidget(qt.HorizontalSpacer()) buttonLayout.addWidget(buttonOK) buttonLayout.addWidget(buttonCancel) msgLayout.addWidget(labelWidth, 0, 0) msgLayout.addWidget(inpWidth, 0, 1) msgLayout.addWidget(labelThreshold, 1, 0) msgLayout.addWidget(inpThreshold, 1, 1) msgLayout.addWidget(buttonActive, 2, 0) msgLayout.addWidget(buttonAll, 2, 1) msgLayout.addLayout(buttonLayout, 3, 0, 1, 2) msg.setLayout(msgLayout) if msg.exec_(): try: self.threshold = float(inpThreshold.value()) / 100. self.threshold = float(inpThreshold.value()) self.width = int(inpWidth.value()) except: self.threshold = 0.66 self.width = 9 if not (self.width % 2): self.width += 1 if buttonActive.isChecked(): if DEBUG: print('ActiveChecked') self.removeSpikesActive() if buttonAll.isChecked(): if DEBUG: print('AllChecked') self.removeSpikesAll()
def __init__(self, parent=None): qt.QWidget.__init__(self, parent) self.mainLayout = qt.QGridLayout(self) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.setSpacing(2) self.__parametersDict = self._getDefaultParameters() self.__defaultEdgeEnergy = None self._polynomOptions = [ 'Modif. Victoreen', 'Victoreen', 'Constant', 'Linear', 'Parabolic', 'Cubic' ] i = 0 edgeGroupBox = qt.QGroupBox(self) edgeGroupBoxLayout = qt.QGridLayout(edgeGroupBox) edgeGroupBox.setAlignment(qt.Qt.AlignHCenter) edgeGroupBox.setTitle('Edge Position') autoButton = qt.QRadioButton(edgeGroupBox) autoButton.setText('Auto') autoButton.setChecked(True) userButton = qt.QRadioButton(edgeGroupBox) userButton.setText('User') buttonGroup = qt.QButtonGroup(edgeGroupBox) buttonGroup.addButton(autoButton, 0) buttonGroup.addButton(userButton, 1) buttonGroup.setExclusive(True) userEnergy = qt.QLineEdit(edgeGroupBox) userEnergy.setEnabled(False) validator = qt.QDoubleValidator(userEnergy) userEnergy.setValidator(validator) edgeGroupBoxLayout.addWidget(autoButton, 0, 0) edgeGroupBoxLayout.addWidget(userButton, 1, 0) edgeGroupBoxLayout.addWidget(userEnergy, 1, 1) self.mainLayout.addWidget(edgeGroupBox, 0, 0, 2, 2) #create handles to the relevant widgets self.autoEdgeButton = autoButton self.userEdgeButton = userButton self.userEdgeEnergy = userEnergy # connect the signals self.connect(buttonGroup, qt.SIGNAL('buttonClicked(int)'), self._buttonClicked) self.connect(self.userEdgeEnergy, qt.SIGNAL('editingFinished()'), self._userEdgeEnergyEditingFinished) regionsGroupBox = qt.QGroupBox(self) regionsGroupBoxLayout = qt.QGridLayout(regionsGroupBox) regionsGroupBox.setAlignment(qt.Qt.AlignHCenter) regionsGroupBox.setTitle('Regions') i = 1 for text in ["Pre-edge Polynom:", "Post-edge Polynom:"]: label = qt.QLabel(regionsGroupBox) label.setText(text) regionsGroupBoxLayout.addWidget(label, i, 0) #self.mainLayout.addWidget(qt.HorizontalSpacer(self), i, 1) i += 1 i = 1 self.widgetDict = {} for key in ['pre_edge', 'post_edge']: self.widgetDict[key] = {} c = 1 w = PolynomSelector(regionsGroupBox, options=self._polynomOptions) self.connect(w, qt.SIGNAL('activated(int)'), self._regionParameterChanged) regionsGroupBoxLayout.addWidget(w, i, c) c += 1 self.widgetDict[key]['polynomial'] = w for text in ['delta xmin', 'delta xmax']: label = qt.QLabel(regionsGroupBox) label.setText(text) self.widgetDict[key][text] = qt.QLineEdit(regionsGroupBox) self.connect(self.widgetDict[key][text], qt.SIGNAL('editingFinished()'), self._regionParameterChanged) validator = qt.QDoubleValidator(self.widgetDict[key][text]) self.widgetDict[key][text].setValidator(validator) regionsGroupBoxLayout.addWidget(label, i, c) regionsGroupBoxLayout.addWidget(self.widgetDict[key][text], i, c + 1) c += 2 i += 1 self.mainLayout.addWidget(regionsGroupBox, 0, 2) self._updateParameters()
def __init__(self, parent=None, options=[1, 2, 3, 4, 5, 10]): qt.QDialog.__init__(self, parent) if QTVERSION < '4.0.0': self.setCaption("NNMA Configuration Dialog") else: self.setWindowTitle("NNMA Configuration Dialog") self.mainLayout = qt.QVBoxLayout(self) self.mainLayout.setMargin(11) self.mainLayout.setSpacing(0) self.infoButton = qt.QPushButton(self) self.infoButton.setAutoDefault(False) self.infoButton.setText('About NNMA') self.mainLayout.addWidget(self.infoButton) self.connect(self.infoButton, qt.SIGNAL('clicked()'), self._showInfo) # self.methodOptions = qt.QGroupBox(self) self.methodOptions.setTitle('NNMA Method to use') self.methods = [ 'RRI', 'NNSC', 'NMF', 'SNMF', 'NMFKL', 'FNMAI', 'ALS', 'FastHALS', 'GDCLS' ] self.methodOptions.mainLayout = qt.QGridLayout(self.methodOptions) self.methodOptions.mainLayout.setMargin(0) self.methodOptions.mainLayout.setSpacing(2) self.buttonGroup = qt.QButtonGroup(self.methodOptions) i = 0 for item in self.methods: rButton = qt.QRadioButton(self.methodOptions) self.methodOptions.mainLayout.addWidget(rButton, 0, i) #self.l.setAlignment(rButton, qt.Qt.AlignHCenter) if i == 1: rButton.setChecked(True) rButton.setText(item) self.buttonGroup.addButton(rButton) self.buttonGroup.setId(rButton, i) i += 1 self.connect(self.buttonGroup, qt.SIGNAL('buttonPressed(QAbstractButton *)'), self._slot) self.mainLayout.addWidget(self.methodOptions) # NNMA configuration parameters self.nnmaConfiguration = qt.QGroupBox(self) self.nnmaConfiguration.setTitle('NNMA Configuration') self.nnmaConfiguration.mainLayout = qt.QGridLayout( self.nnmaConfiguration) self.nnmaConfiguration.mainLayout.setMargin(0) self.nnmaConfiguration.mainLayout.setSpacing(2) label = qt.QLabel(self.nnmaConfiguration) label.setText('Tolerance (0<eps<1000:') self._tolerance = qt.QLineEdit(self.nnmaConfiguration) validator = qt.QDoubleValidator(self._tolerance) self._tolerance.setValidator(validator) self._tolerance._validator = validator self._tolerance.setText("0.001") self.nnmaConfiguration.mainLayout.addWidget(label, 0, 0) self.nnmaConfiguration.mainLayout.addWidget(self._tolerance, 0, 1) label = qt.QLabel(self.nnmaConfiguration) label.setText('Maximum iterations:') self._maxIterations = qt.QSpinBox(self.nnmaConfiguration) self._maxIterations.setMinimum(1) self._maxIterations.setMaximum(1000) self._maxIterations.setValue(100) self.nnmaConfiguration.mainLayout.addWidget(label, 1, 0) self.nnmaConfiguration.mainLayout.addWidget(self._maxIterations, 1, 1) self.mainLayout.addWidget(self.nnmaConfiguration) #built in speed options self.speedOptions = qt.QGroupBox(self) self.speedOptions.setTitle("Speed Options") self.speedOptions.mainLayout = qt.QGridLayout(self.speedOptions) self.speedOptions.mainLayout.setMargin(0) self.speedOptions.mainLayout.setSpacing(2) labelPC = qt.QLabel(self) labelPC.setText("Number of PC:") self.nPC = qt.QSpinBox(self.speedOptions) self.nPC.setMinimum(0) self.nPC.setValue(10) self.nPC.setMaximum(40) self.binningLabel = qt.QLabel(self.speedOptions) self.binningLabel.setText("Spectral Binning:") self.binningCombo = qt.QComboBox(self.speedOptions) for option in options: self.binningCombo.addItem("%d" % option) self.speedOptions.mainLayout.addWidget(labelPC, 0, 0) self.speedOptions.mainLayout.addWidget(self.nPC, 0, 1) #self.speedOptions.mainLayout.addWidget(qt.HorizontalSpacer(self), 0, 2) self.speedOptions.mainLayout.addWidget(self.binningLabel, 1, 0) self.speedOptions.mainLayout.addWidget(self.binningCombo, 1, 1) self.binningCombo.setEnabled(True) #the OK button hbox = qt.QWidget(self) hboxLayout = qt.QHBoxLayout(hbox) hboxLayout.setMargin(0) hboxLayout.setSpacing(0) self.okButton = qt.QPushButton(hbox) self.okButton.setAutoDefault(False) self.okButton.setText("Accept") hboxLayout.addWidget(qt.HorizontalSpacer(hbox)) hboxLayout.addWidget(self.okButton) self.dismissButton = qt.QPushButton(hbox) self.dismissButton.setAutoDefault(False) self.dismissButton.setText("Dismiss") hboxLayout.addWidget(qt.HorizontalSpacer(hbox)) hboxLayout.addWidget(self.dismissButton) hboxLayout.addWidget(qt.HorizontalSpacer(hbox)) self.mainLayout.addWidget(self.speedOptions) self.mainLayout.addWidget(hbox) self.connect(self.okButton, qt.SIGNAL("clicked()"), self.accept) self.connect(self.dismissButton, qt.SIGNAL("clicked()"), self.reject) self._infoDocument = qt.QTextEdit() self._infoDocument.setReadOnly(True) self._infoDocument.setText(NNMAModule.__doc__) self._infoDocument.hide() self.mainLayout.addWidget(self._infoDocument)
def __init__(self, parent=None, options=[1, 2, 3, 4, 5, 10], regions=False): qt.QDialog.__init__(self, parent) if QTVERSION < '4.0.0': self.setCaption("PCA Configuration Dialog") else: self.setWindowTitle("PCA Configuration Dialog") self.mainLayout = qt.QVBoxLayout(self) self.mainLayout.setMargin(11) self.mainLayout.setSpacing(0) self.methodOptions = qt.QGroupBox(self) self.methodOptions.setTitle('PCA Method to use') self.methods = [ 'Covariance', 'Expectation Max.', 'Cov. Multiple Arrays' ] self.functions = [ PCAModule.numpyPCA, PCAModule.expectationMaximizationPCA, PCAModule.multipleArrayPCA ] self.methodOptions.mainLayout = qt.QGridLayout(self.methodOptions) self.methodOptions.mainLayout.setMargin(0) self.methodOptions.mainLayout.setSpacing(2) #this does not seem to bring any advantage if 0: self.methods.append("Covariance Numpy") self.functions.append(PCAModule.numpyPCA) if MDP: #self.methods.append("MDP (PCA + ICA)") self.methods.append("MDP (SVD float32)") self.methods.append("MDP (SVD float64)") self.methods.append("MDP ICA (float32)") self.methods.append("MDP ICA (float64)") self.functions.append(PCAModule.mdpPCASVDFloat32) self.functions.append(PCAModule.mdpPCASVDFloat64) self.functions.append(PCAModule.mdpICAFloat32) self.functions.append(PCAModule.mdpICAFloat64) self.buttonGroup = qt.QButtonGroup(self.methodOptions) i = 0 for item in self.methods: rButton = qt.QRadioButton(self.methodOptions) self.methodOptions.mainLayout.addWidget(rButton, 0, i) #self.l.setAlignment(rButton, qt.Qt.AlignHCenter) if i == 1: rButton.setChecked(True) rButton.setText(item) self.buttonGroup.addButton(rButton) self.buttonGroup.setId(rButton, i) i += 1 self.connect(self.buttonGroup, qt.SIGNAL('buttonPressed(QAbstractButton *)'), self._slot) self.mainLayout.addWidget(self.methodOptions) #built in speed options self.speedOptions = qt.QGroupBox(self) self.speedOptions.setTitle("Speed Options") self.speedOptions.mainLayout = qt.QGridLayout(self.speedOptions) self.speedOptions.mainLayout.setMargin(0) self.speedOptions.mainLayout.setSpacing(2) labelPC = qt.QLabel(self) labelPC.setText("Number of PC:") self.nPC = qt.QSpinBox(self.speedOptions) self.nPC.setMinimum(0) self.nPC.setValue(10) self.nPC.setMaximum(40) self.binningLabel = qt.QLabel(self.speedOptions) self.binningLabel.setText("Spectral Binning:") self.binningCombo = qt.QComboBox(self.speedOptions) for option in options: self.binningCombo.addItem("%d" % option) self.speedOptions.mainLayout.addWidget(labelPC, 0, 0) self.speedOptions.mainLayout.addWidget(self.nPC, 0, 1) #self.speedOptions.mainLayout.addWidget(qt.HorizontalSpacer(self), 0, 2) self.speedOptions.mainLayout.addWidget(self.binningLabel, 1, 0) self.speedOptions.mainLayout.addWidget(self.binningCombo, 1, 1) self.binningCombo.setEnabled(False) self.connect(self.binningCombo, qt.SIGNAL("activated(int)"), self._updatePlotFromBinningCombo) if regions: self.__regions = True self.__addRegionsWidget() else: self.__regions = False #the optional plot self.scanWindow = None #the OK button hbox = qt.QWidget(self) hboxLayout = qt.QHBoxLayout(hbox) hboxLayout.setMargin(0) hboxLayout.setSpacing(0) self.okButton = qt.QPushButton(hbox) self.okButton.setText("Accept") self.okButton.setAutoDefault(False) hboxLayout.addWidget(qt.HorizontalSpacer(hbox)) hboxLayout.addWidget(self.okButton) hboxLayout.addWidget(qt.HorizontalSpacer(hbox)) self.mainLayout.addWidget(self.speedOptions) if regions: self.mainLayout.addWidget(self.regionsWidget) self.mainLayout.addWidget(hbox) if self.scanWindow is not None: self.mainLayout.addWidget(self.scanWindow) self.connect(self.okButton, qt.SIGNAL("clicked()"), self.accept)