def _buildNorm(self): self._qgbNorm = qt.QGroupBox(parent=self) self._qgbNorm.setLayout(qt.QHBoxLayout()) self._qgbNorm._qrbLinear = qt.QRadioButton('linear') self._qgbNorm._qrbLog = qt.QRadioButton('log') self._qgbNorm.layout().addWidget(self._qgbNorm._qrbLinear) self._qgbNorm.layout().addWidget(self._qgbNorm._qrbLog)
def setupUi(self): # form layout for grid scan inputs layout = qt.QFormLayout() self.noChangeBox = qt.QRadioButton() layout.addRow(qt.QLabel("Export flat list of points:"), self.noChangeBox) self.reshapeBox = qt.QRadioButton() self.reshapeBox.setChecked(True) layout.addRow(qt.QLabel("Try reshaping the data:"), self.reshapeBox) self.shapeBox = qt.QLineEdit('auto') layout.addRow(qt.QLabel(" shape:"), self.shapeBox) self.resampleBox = qt.QRadioButton() layout.addRow(qt.QLabel("Resample the data on a grid:"), self.resampleBox) self.oversamplingBox = qt.QSpinBox() self.oversamplingBox.setValue(1) layout.addRow(qt.QLabel(" oversampling relative to typical step size:"), self.oversamplingBox) self.equalBox = qt.QCheckBox() self.equalBox.setChecked(True) layout.addRow(qt.QLabel(" equal horizontal and vertical steps"), self.equalBox) self.formGroupBox = qt.QGroupBox("PyMCA needs data layed out on a regular grid.") self.formGroupBox.setLayout(layout) # ok/cancel buttons buttonBox = qt.QDialogButtonBox(qt.QDialogButtonBox.Ok | qt.QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) # put everything together mainLayout = qt.QVBoxLayout() mainLayout.addWidget(self.formGroupBox) mainLayout.addWidget(buttonBox) self.setLayout(mainLayout) self.setWindowTitle("Export for PyMCA...")
def __init__(self, parent=None): """Constructor :param QWidget parent: The parent of the widget """ super(DataViewer, self).__init__(parent) self.__stack = qt.QStackedWidget(self) self.__numpySelection = NumpyAxesSelector(self) self.__numpySelection.selectedAxisChanged.connect(self.__numpyAxisChanged) self.__numpySelection.selectionChanged.connect(self.__numpySelectionChanged) self.__numpySelection.customAxisChanged.connect(self.__numpyCustomAxisChanged) self.setLayout(qt.QVBoxLayout(self)) self.layout().addWidget(self.__stack, 1) group = qt.QGroupBox(self) group.setLayout(qt.QVBoxLayout()) group.layout().addWidget(self.__numpySelection) group.setTitle("Axis selection") self.__axisSelection = group self.layout().addWidget(self.__axisSelection) self.__currentAvailableViews = [] self.__currentView = None self.__data = None self.__useAxisSelection = False self.__userSelectedView = None self.__views = [] self.__index = {} """store stack index for each views""" self._initializeViews()
def _initOtherToolsGroupBox(self): layout = qt.QVBoxLayout() self.maskNanBtn = qt.QPushButton('Mask not finite values') self.maskNanBtn.setToolTip('Mask Not a Number and infinite values') self.maskNanBtn.clicked.connect(self._maskNotFiniteBtnClicked) layout.addWidget(self.maskNanBtn) self.otherToolGroup = qt.QGroupBox('Other tools') self.otherToolGroup.setLayout(layout) return self.otherToolGroup
def createTreeViewConfigurationPanel(self, parent, treeview): """Create a configuration panel to allow to play with widget states""" panel = qt.QWidget(parent) panel.setLayout(qt.QHBoxLayout()) content = qt.QGroupBox("Create HDF5", panel) content.setLayout(qt.QVBoxLayout()) panel.layout().addWidget(content) combo = qt.QComboBox() combo.addItem("Containing all types", get_hdf5_with_all_types) combo.activated.connect(self.__hdf5ComboChanged) content.layout().addWidget(combo) button = ThreadPoolPushButton(content, text="Create") button.setCallable(combo.itemData(combo.currentIndex())) button.succeeded.connect(self.__fileCreated) content.layout().addWidget(button) self.__hdf5Combo = combo self.__createHdf5Button = button content.layout().addStretch(1) option = qt.QGroupBox("Custom model", panel) option.setLayout(qt.QVBoxLayout()) panel.layout().addWidget(option) button = qt.QPushButton("Original model") button.clicked.connect(self.__useOriginalModel) option.layout().addWidget(button) button = qt.QPushButton("Custom tooltips by composition") button.clicked.connect(self.__useCustomLabel) option.layout().addWidget(button) option.layout().addStretch(1) panel.layout().addStretch(1) return panel
def makeColorGroup(self): self.colorIndividual = qt.QRadioButton("individual") self.colorIndividualButton = QColorLoop(self, [self.color]) self.colorIndividualButton.clicked.connect( partial(self.openColorDialog, gco.COLOR_POLICY_INDIVIDUAL)) self.colorLoop1 = qt.QRadioButton("loop1") self.colorLoop1Button = QColorLoop(self, gco.colorCycle1) self.colorLoop1Button.clicked.connect( partial(self.openColorDialog, gco.COLOR_POLICY_LOOP1)) self.colorLoop2 = qt.QRadioButton("loop2") self.colorLoop2Button = QColorLoop(self, gco.colorCycle2) self.colorLoop2Button.clicked.connect( partial(self.openColorDialog, gco.COLOR_POLICY_LOOP2)) self.colorGradient = qt.QRadioButton("gradient") gradient = gco.makeGradientCollection(self.color1, self.color2) self.colorGradientButton = QColorLoop(self, gradient) self.colorGradientButton.clicked.connect( partial(self.openColorDialog, gco.COLOR_POLICY_GRADIENT)) self.colorAutoCollective = qt.QCheckBox( "keep collective color rule\nwhen data model changes") self.colorAutoCollective.setEnabled(self.isGroupSelected or self.isTopGroupSelected) self.colorRadioButtons = (self.colorIndividualButton, self.colorLoop1, self.colorLoop2, self.colorGradient) layoutC = qt.QVBoxLayout() layoutC.setContentsMargins(10, 0, 2, 2) layoutH = qt.QHBoxLayout() layoutH.addWidget(self.colorIndividual) layoutH.addWidget(self.colorIndividualButton) layoutC.addLayout(layoutH) layoutH = qt.QHBoxLayout() layoutH.addWidget(self.colorLoop1) layoutH.addWidget(self.colorLoop1Button) layoutC.addLayout(layoutH) layoutH = qt.QHBoxLayout() layoutH.addWidget(self.colorLoop2) layoutH.addWidget(self.colorLoop2Button) layoutC.addLayout(layoutH) layoutH = qt.QHBoxLayout() layoutH.addWidget(self.colorGradient) layoutH.addWidget(self.colorGradientButton) layoutC.addLayout(layoutH) layoutC.addWidget(self.colorAutoCollective) groupColor = qt.QGroupBox('Color:') groupColor.setLayout(layoutC) return groupColor
def createOptions(self): panel = qt.QGroupBox() panel.setTitle("Options") layout = qt.QVBoxLayout() panel.setLayout(layout) group = qt.QButtonGroup(panel) radio = qt.QRadioButton(panel) radio.setText("Qt QFileDialog") radio.setProperty("Mode", Mode.DEFAULT_FILEDIALOG) group.addButton(radio) layout.addWidget(radio) radio = qt.QRadioButton(panel) radio.setText("silx ImageFileDialog") radio.setProperty("Mode", Mode.IMAGEFILEDIALOG) group.addButton(radio) layout.addWidget(radio) radio = qt.QRadioButton(panel) radio.setChecked(True) radio.setText("silx DataFileDialog") radio.setProperty("Mode", Mode.DATAFILEDIALOG) group.addButton(radio) layout.addWidget(radio) radio = qt.QRadioButton(panel) radio.setText("silx DataFileDialog (filter=dataset)") radio.setProperty("Mode", Mode.DATAFILEDIALOG_DATASET) group.addButton(radio) layout.addWidget(radio) radio = qt.QRadioButton(panel) radio.setText("silx DataFileDialog (filter=group)") radio.setProperty("Mode", Mode.DATAFILEDIALOG_GROUP) group.addButton(radio) layout.addWidget(radio) radio = qt.QRadioButton(panel) radio.setText("silx DataFileDialog (filter=NXentry)") radio.setProperty("Mode", Mode.DATAFILEDIALOG_NXENTRY) group.addButton(radio) layout.addWidget(radio) self.__options = group return panel
def _buildActiveImageSelector(self): """Build the image selector widget""" self.image_selector = qt.QGroupBox(parent=self) self.image_selector.setLayout(qt.QVBoxLayout()) self.image_selector._qr1 = qt.QRadioButton('image1') self.image_selector._qr1.setChecked(True) self.image_selector._qr2 = qt.QRadioButton('image2') self.image_selector._qr3 = qt.QRadioButton('image3') self.image_selector._qr4 = qt.QRadioButton('image4') self.image_selector._qr5 = qt.QRadioButton('image5') self.image_selector._qr6 = qt.QRadioButton('image6') self.image_selector.layout().addWidget(self.image_selector._qr6) self.image_selector.layout().addWidget(self.image_selector._qr5) self.image_selector.layout().addWidget(self.image_selector._qr4) self.image_selector.layout().addWidget(self.image_selector._qr3) self.image_selector.layout().addWidget(self.image_selector._qr2) self.image_selector.layout().addWidget(self.image_selector._qr1)
def __init__(self, parent=None): super(DialogExample, self).__init__(parent) self.__state = {} centralWidget = qt.QWidget(self) layout = qt.QHBoxLayout() centralWidget.setLayout(layout) options = self.createOptions() layout.addWidget(options) buttonGroup = qt.QGroupBox() buttonGroup.setTitle("Create dialog") layout.addWidget(buttonGroup) buttonLayout = qt.QVBoxLayout() buttonGroup.setLayout(buttonLayout) # ImageFileDialog b1 = qt.QPushButton(self) b1.setMinimumHeight(50) b1.setText("Open a dialog") b1.clicked.connect(self.openDialog) buttonLayout.addWidget(b1) b2 = qt.QPushButton(self) b2.setMinimumHeight(50) b2.setText("Open a dialog with state stored") b2.clicked.connect(self.openDialogStoredState) buttonLayout.addWidget(b2) b3 = qt.QPushButton(self) b3.setMinimumHeight(50) b3.setText("Open a dialog at home") b3.clicked.connect(self.openDialogAtHome) buttonLayout.addWidget(b3) b4 = qt.QPushButton(self) b4.setMinimumHeight(50) b4.setText("Open a dialog at computer root") b4.clicked.connect(self.openDialogAtComputer) buttonLayout.addWidget(b4) self.setCentralWidget(centralWidget)
def layout_widgets(self): flyInfoWg = qt.QWidget(self) flyInfoWg.setLayout(qt.QVBoxLayout()) flyInfoWg.layout().addWidget( addLabelWidget("Calculated motor speed [Deg/sec] : ", self.flyMotorSpeed, labelWidth=250, align='right')) flyInfoWg.layout().addWidget( addLabelWidget("Encoder Steps per Point : ", self.flyEncoderStepSize, labelWidth=250, align='right')) flyInfoWg.layout().addWidget( addLabelWidget("Estimated Number of Scan Points : ", self.flyNumOfPoints, labelWidth=250, align='right')) self.main_panel.layout().addWidget(flyInfoWg) scanSetupGB = qt.QGroupBox("Fly Scan Setup", self) scanSetupGB.setLayout(qt.QVBoxLayout()) scanSetupGB.layout().addWidget( addWidgets([ addLabelWidgetVert( "Start energy[eV]", self.flyStartE, align='center'), addLabelWidgetVert( "Stop energy[eV]", self.flyStopE, align='center'), addLabelWidgetVert( "Resolution[eV]", self.flyResolutionE, align='center'), addLabelWidgetVert( "Scan Time[s]", self.flyScanTime, align='center') ], align='uniform')) scanSetupGB.layout().addWidget( addLabelWidget("Cooling Time[s]", self.flyCoolTime, align='right')) self.main_panel.layout().addWidget(scanSetupGB)
def makeCombineDataGroup(self): self.combineType = qt.QComboBox() self.combineType.addItems(csp.combineNames) self.combineType.currentIndexChanged.connect(self.combineTypeChanged) self.combineNLabel = qt.QLabel("N=") self.combineN = qt.QSpinBox() self.combineN.setMinimum(1) self.combineStopCB = qt.QCheckBox( u"stop propagation of\ncontributing data at:") self.combineStopCB.stateChanged.connect(self.combineStopCBChanged) self.combineStop = qt.QComboBox() self.combineStop.addItems(csi.nodes.keys()) self.combineMoveToGroupCB = qt.QCheckBox( u"move selected data to a new group") self.combineDo = qt.QPushButton("Combine") self.combineDo.clicked.connect(self.createCombined) # layout = qt.QVBoxLayout() # layout.addWidget(self.combineType) # layout.addWidget(self.combineStopCB) # layout.addWidget(self.combineStop) # layout.addWidget(self.combineDo) # layout.addStretch() layout = qt.QGridLayout() layout.setContentsMargins(2, 0, 2, 2) layout.addWidget(self.combineType, 0, 0) layoutN = qt.QHBoxLayout() layoutN.addStretch() layoutN.addWidget(self.combineNLabel) layoutN.addWidget(self.combineN) layout.addLayout(layoutN, 0, 1) layout.addWidget(self.combineStopCB, 1, 0) layout.addWidget(self.combineStop, 1, 1) layout.addWidget(self.combineMoveToGroupCB, 2, 0, 1, 2) layout.addWidget(self.combineDo, 3, 0, 1, 2) group = qt.QGroupBox('combine selected data') group.setLayout(layout) # group.setSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Fixed) return group
def __init__(self, parent=None, dirname=''): super(SaveProjectDlg, self).__init__(parent=parent, caption='Save project', directory=dirname) self.setOption(qt.QFileDialog.DontUseNativeDialog, True) self.setAcceptMode(qt.QFileDialog.AcceptSave) self.setFileMode(qt.QFileDialog.AnyFile) self.setViewMode(qt.QFileDialog.Detail) self.setNameFilter("ParSeq Project File (*.pspj)") selNames = [it.alias for it in csi.selectedItems] combinedNames = cco.combine_names(selNames) sellen = len(csi.selectedItems) exportStr = 'export data of {0} selected item{1}: {2}'.format( sellen, 's' if sellen > 1 else '', combinedNames) if sellen < 4 \ else 'export data of {0} selected items'.format(sellen) self.saveData = qt.QGroupBox(exportStr, self) self.saveData.setCheckable(True) self.saveData.setChecked(True) layoutC = qt.QHBoxLayout() layoutC.setContentsMargins(0, 2, 0, 0) saveDataFrom = qt.QGroupBox('from nodes', self) layoutF = qt.QVBoxLayout() layoutF.setContentsMargins(4, 4, 4, 4) self.saveNodeCBs = [] for i, (name, node) in enumerate(csi.nodes.items()): tabName = u'{0} \u2013 {1}'.format(i + 1, name) nodeCB = qt.QCheckBox(tabName, self) self.saveNodeCBs.append(nodeCB) layoutF.addWidget(nodeCB) nodeCB.setChecked(True) saveDataFrom.setLayout(layoutF) layoutC.addWidget(saveDataFrom) saveDataAs = qt.QGroupBox('as', self) layoutA = qt.QVBoxLayout() layoutA.setContentsMargins(4, 4, 4, 4) self.saveAsCBs = [] for i, dtype in enumerate(ftypes): asCB = qt.QCheckBox(dtype, self) self.saveAsCBs.append(asCB) layoutA.addWidget(asCB) self.saveAsCBs[0].setChecked(True) saveDataAs.setLayout(layoutA) layoutC.addWidget(saveDataAs) layoutP = qt.QVBoxLayout() self.scriptCBmpl = qt.QCheckBox( 'save a matplotlib plotting script\nfor the exported data', self) layoutP.addWidget(self.scriptCBmpl, alignment=qt.Qt.AlignTop) self.scriptCBsilx = qt.QCheckBox( 'save a silx plotting script\nfor the exported data', self) layoutP.addWidget(self.scriptCBsilx, alignment=qt.Qt.AlignTop) layoutP.addStretch() layoutC.addLayout(layoutP) self.saveData.setLayout(layoutC) self.layout().addWidget(self.saveData, self.layout().rowCount(), 0, 1, 2) self.layout().setRowStretch(self.layout().rowCount(), 0) self.finished.connect(self.onFinish)
def __createConfigurationPanel(self, parent): panel = qt.QWidget(parent=parent) layout = qt.QVBoxLayout() panel.setLayout(layout) self.__kind = qt.QButtonGroup(self) self.__kind.setExclusive(True) group = qt.QGroupBox(self) group.setTitle("Image") layout.addWidget(group) groupLayout = qt.QVBoxLayout(group) button = qt.QRadioButton(parent=panel) button.setText("Island") button.clicked.connect(self.generateIsland) button.setCheckable(True) button.setChecked(True) groupLayout.addWidget(button) self.__kind.addButton(button) button = qt.QRadioButton(parent=panel) button.setText("Gravity") button.clicked.connect(self.generateGravityField) button.setCheckable(True) groupLayout.addWidget(button) self.__kind.addButton(button) button = qt.QRadioButton(parent=panel) button.setText("Magnetic") button.clicked.connect(self.generateMagneticField) button.setCheckable(True) groupLayout.addWidget(button) self.__kind.addButton(button) button = qt.QRadioButton(parent=panel) button.setText("Spiral") button.clicked.connect(self.generateSpiral) button.setCheckable(True) groupLayout.addWidget(button) self.__kind.addButton(button) button = qt.QRadioButton(parent=panel) button.setText("Gradient") button.clicked.connect(self.generateGradient) button.setCheckable(True) groupLayout.addWidget(button) self.__kind.addButton(button) button = qt.QRadioButton(parent=panel) button.setText("Composite gradient") button.clicked.connect(self.generateCompositeGradient) button.setCheckable(True) groupLayout.addWidget(button) self.__kind.addButton(button) button = qt.QPushButton(parent=panel) button.setText("Generate a new image") button.clicked.connect(self.generate) groupLayout.addWidget(button) # Contours group = qt.QGroupBox(self) group.setTitle("Contours") layout.addWidget(group) groupLayout = qt.QVBoxLayout(group) button = qt.QCheckBox(parent=panel) button.setText("Use the plot's mask") button.setCheckable(True) button.setChecked(True) button.clicked.connect(self.updateContours) groupLayout.addWidget(button) self.__useMaskButton = button button = qt.QPushButton(parent=panel) button.setText("Update contours") button.clicked.connect(self.updateContours) groupLayout.addWidget(button) # Implementations group = qt.QGroupBox(self) group.setTitle("Implementation") layout.addWidget(group) groupLayout = qt.QVBoxLayout(group) self.__impl = qt.QButtonGroup(self) self.__impl.setExclusive(True) button = qt.QRadioButton(parent=panel) button.setText("silx") button.clicked.connect(self.updateContours) button.setCheckable(True) button.setChecked(True) groupLayout.addWidget(button) self.__implMerge = button self.__impl.addButton(button) button = qt.QRadioButton(parent=panel) button.setText("silx with cache") button.clicked.connect(self.updateContours) button.setCheckable(True) groupLayout.addWidget(button) self.__implMergeCache = button self.__impl.addButton(button) button = qt.QRadioButton(parent=panel) button.setText("skimage") button.clicked.connect(self.updateContours) button.setCheckable(True) groupLayout.addWidget(button) self.__implSkimage = button self.__impl.addButton(button) if MarchingSquaresSciKitImage is None: button.setEnabled(False) button.setToolTip("skimage is not installed or not compatible") # Processing group = qt.QGroupBox(self) group.setTitle("Processing") layout.addWidget(group) group.setLayout(self.__createInfoLayout(group)) # Processing group = qt.QGroupBox(self) group.setTitle("Custom level") layout.addWidget(group) groupLayout = qt.QVBoxLayout(group) label = qt.QLabel(parent=panel) self.__value = qt.QSlider(panel) self.__value.setOrientation(qt.Qt.Horizontal) self.__value.sliderMoved.connect(self.__updateCustomContours) self.__value.valueChanged.connect(self.__updateCustomContours) groupLayout.addWidget(self.__value) return panel
def _initThresholdGroupBox(self): """Init thresholding widgets""" self.belowThresholdAction = qt.QAction( icons.getQIcon('plot-roi-below'), 'Mask below threshold', None) self.belowThresholdAction.setToolTip( 'Mask image where values are below given threshold') self.belowThresholdAction.setCheckable(True) self.belowThresholdAction.setChecked(True) self.betweenThresholdAction = qt.QAction( icons.getQIcon('plot-roi-between'), 'Mask within range', None) self.betweenThresholdAction.setToolTip( 'Mask image where values are within given range') self.betweenThresholdAction.setCheckable(True) self.aboveThresholdAction = qt.QAction( icons.getQIcon('plot-roi-above'), 'Mask above threshold', None) self.aboveThresholdAction.setToolTip( 'Mask image where values are above given threshold') self.aboveThresholdAction.setCheckable(True) self.thresholdActionGroup = qt.QActionGroup(self) self.thresholdActionGroup.setExclusive(True) self.thresholdActionGroup.addAction(self.belowThresholdAction) self.thresholdActionGroup.addAction(self.betweenThresholdAction) self.thresholdActionGroup.addAction(self.aboveThresholdAction) self.thresholdActionGroup.triggered.connect( self._thresholdActionGroupTriggered) self.loadColormapRangeAction = qt.QAction( icons.getQIcon('view-refresh'), 'Set min-max from colormap', None) self.loadColormapRangeAction.setToolTip( 'Set min and max values from current colormap range') self.loadColormapRangeAction.setCheckable(False) self.loadColormapRangeAction.triggered.connect( self._loadRangeFromColormapTriggered) widgets = [] for action in self.thresholdActionGroup.actions(): btn = qt.QToolButton() btn.setDefaultAction(action) widgets.append(btn) spacer = qt.QWidget() spacer.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Preferred) widgets.append(spacer) loadColormapRangeBtn = qt.QToolButton() loadColormapRangeBtn.setDefaultAction(self.loadColormapRangeAction) widgets.append(loadColormapRangeBtn) toolBar = self._hboxWidget(*widgets, stretch=False) config = qt.QGridLayout() config.setContentsMargins(0, 0, 0, 0) self.minLineLabel = qt.QLabel("Min:", self) self.minLineEdit = FloatEdit(self, value=0) config.addWidget(self.minLineLabel, 0, 0) config.addWidget(self.minLineEdit, 0, 1) self.maxLineLabel = qt.QLabel("Max:", self) self.maxLineEdit = FloatEdit(self, value=0) config.addWidget(self.maxLineLabel, 1, 0) config.addWidget(self.maxLineEdit, 1, 1) self.applyMaskBtn = qt.QPushButton('Apply mask') self.applyMaskBtn.clicked.connect(self._maskBtnClicked) layout = qt.QVBoxLayout() layout.addWidget(toolBar) layout.addLayout(config) layout.addWidget(self.applyMaskBtn) self.thresholdGroup = qt.QGroupBox('Threshold') self.thresholdGroup.setLayout(layout) # Init widget state self._thresholdActionGroupTriggered(self.belowThresholdAction) return self.thresholdGroup
def __init__(self, parent=None): super(SearchPage, self).__init__(parent) layout = qt.QVBoxLayout(self) self.manualFwhmGB = qt.QGroupBox("Define FWHM manually", self) self.manualFwhmGB.setCheckable(True) self.manualFwhmGB.setToolTip( "If disabled, the FWHM parameter used for peak search is " + "estimated based on the highest peak in the data") layout.addWidget(self.manualFwhmGB) # ------------ GroupBox fwhm-------------------------- layout2 = qt.QHBoxLayout(self.manualFwhmGB) self.manualFwhmGB.setLayout(layout2) label = qt.QLabel("Fwhm Points", self.manualFwhmGB) layout2.addWidget(label) self.fwhmPointsSpin = qt.QSpinBox(self.manualFwhmGB) self.fwhmPointsSpin.setRange(0, 999999) self.fwhmPointsSpin.setToolTip( "Typical peak fwhm (number of data points)") layout2.addWidget(self.fwhmPointsSpin) # ---------------------------------------------------- self.manualScalingGB = qt.QGroupBox("Define scaling manually", self) self.manualScalingGB.setCheckable(True) self.manualScalingGB.setToolTip( "If disabled, the Y scaling used for peak search is " + "estimated automatically") layout.addWidget(self.manualScalingGB) # ------------ GroupBox scaling----------------------- layout3 = qt.QHBoxLayout(self.manualScalingGB) self.manualScalingGB.setLayout(layout3) label = qt.QLabel("Y Scaling", self.manualScalingGB) layout3.addWidget(label) self.yScalingEntry = qt.QLineEdit(self.manualScalingGB) self.yScalingEntry.setToolTip( "Data values will be multiplied by this value prior to peak" + " search") self.yScalingEntry.setValidator(qt.QDoubleValidator(self)) layout3.addWidget(self.yScalingEntry) # ---------------------------------------------------- # ------------------- grid layout -------------------- containerWidget = qt.QWidget(self) layout4 = qt.QHBoxLayout(containerWidget) containerWidget.setLayout(layout4) label = qt.QLabel("Sensitivity", containerWidget) layout4.addWidget(label) self.sensitivityEntry = qt.QLineEdit(containerWidget) self.sensitivityEntry.setToolTip( "Peak search sensitivity threshold, expressed as a multiple " + "of the standard deviation of the noise.\nMinimum value is 1 " + "(to be detected, peak must be higher than the estimated noise)") sensivalidator = qt.QDoubleValidator(self) sensivalidator.setBottom(1.0) self.sensitivityEntry.setValidator(sensivalidator) layout4.addWidget(self.sensitivityEntry) # ---------------------------------------------------- layout.addWidget(containerWidget) self.forcePeakPresenceCB = qt.QCheckBox("Force peak presence", self) self.forcePeakPresenceCB.setToolTip( "If peak search algorithm is unsuccessful, place one peak " + "at the maximum of the curve") layout.addWidget(self.forcePeakPresenceCB) layout.addStretch() self.setDefault()
def _initMaskGroupBox(self): """Init general mask operation widgets""" # Mask level self.levelSpinBox = qt.QSpinBox() self.levelSpinBox.setRange(1, self._maxLevelNumber) self.levelSpinBox.setToolTip( 'Choose which mask level is edited.\n' 'A mask can have up to 255 non-overlapping levels.') self.levelSpinBox.valueChanged[int].connect(self._updateColors) self.levelWidget = self._hboxWidget(qt.QLabel('Mask level:'), self.levelSpinBox) # Transparency self.transparencyWidget = self._initTransparencyWidget() # Buttons group invertBtn = qt.QPushButton('Invert') invertBtn.setShortcut(qt.Qt.CTRL + qt.Qt.Key_I) invertBtn.setToolTip('Invert current mask <b>%s</b>' % invertBtn.shortcut().toString()) invertBtn.clicked.connect(self._handleInvertMask) clearBtn = qt.QPushButton('Clear') clearBtn.setShortcut(qt.QKeySequence.Delete) clearBtn.setToolTip('Clear current mask level <b>%s</b>' % clearBtn.shortcut().toString()) clearBtn.clicked.connect(self._handleClearMask) invertClearWidget = self._hboxWidget(invertBtn, clearBtn, stretch=False) undoBtn = qt.QPushButton('Undo') undoBtn.setShortcut(qt.QKeySequence.Undo) undoBtn.setToolTip('Undo last mask change <b>%s</b>' % undoBtn.shortcut().toString()) self._mask.sigUndoable.connect(undoBtn.setEnabled) undoBtn.clicked.connect(self._mask.undo) redoBtn = qt.QPushButton('Redo') redoBtn.setShortcut(qt.QKeySequence.Redo) redoBtn.setToolTip('Redo last undone mask change <b>%s</b>' % redoBtn.shortcut().toString()) self._mask.sigRedoable.connect(redoBtn.setEnabled) redoBtn.clicked.connect(self._mask.redo) undoRedoWidget = self._hboxWidget(undoBtn, redoBtn, stretch=False) self.clearAllBtn = qt.QPushButton('Clear all') self.clearAllBtn.setToolTip('Clear all mask levels') self.clearAllBtn.clicked.connect(self.resetSelectionMask) loadBtn = qt.QPushButton('Load...') loadBtn.clicked.connect(self._loadMask) saveBtn = qt.QPushButton('Save...') saveBtn.clicked.connect(self._saveMask) self.loadSaveWidget = self._hboxWidget(loadBtn, saveBtn, stretch=False) layout = qt.QVBoxLayout() layout.addWidget(self.levelWidget) layout.addWidget(self.transparencyWidget) layout.addWidget(invertClearWidget) layout.addWidget(undoRedoWidget) layout.addWidget(self.clearAllBtn) layout.addWidget(self.loadSaveWidget) layout.addStretch(1) maskGroup = qt.QGroupBox('Mask') maskGroup.setLayout(layout) return maskGroup
def _initDrawGroupBox(self): """Init drawing tools widgets""" layout = qt.QVBoxLayout() self.browseAction = PanModeAction(self.plot, self.plot) self.addAction(self.browseAction) # Draw tools self.rectAction = qt.QAction(icons.getQIcon('shape-rectangle'), 'Rectangle selection', None) self.rectAction.setToolTip( 'Rectangle selection tool: (Un)Mask a rectangular region <b>R</b>') self.rectAction.setShortcut(qt.QKeySequence(qt.Qt.Key_R)) self.rectAction.setCheckable(True) self.rectAction.triggered.connect(self._activeRectMode) self.addAction(self.rectAction) self.ellipseAction = qt.QAction(icons.getQIcon('shape-ellipse'), 'Circle selection', None) self.ellipseAction.setToolTip( 'Rectangle selection tool: (Un)Mask a circle region <b>R</b>') self.ellipseAction.setShortcut(qt.QKeySequence(qt.Qt.Key_R)) self.ellipseAction.setCheckable(True) self.ellipseAction.triggered.connect(self._activeEllipseMode) self.addAction(self.ellipseAction) self.polygonAction = qt.QAction(icons.getQIcon('shape-polygon'), 'Polygon selection', None) self.polygonAction.setShortcut(qt.QKeySequence(qt.Qt.Key_S)) self.polygonAction.setToolTip( 'Polygon selection tool: (Un)Mask a polygonal region <b>S</b><br>' 'Left-click to place new polygon corners<br>' 'Left-click on first corner to close the polygon') self.polygonAction.setCheckable(True) self.polygonAction.triggered.connect(self._activePolygonMode) self.addAction(self.polygonAction) self.pencilAction = qt.QAction(icons.getQIcon('draw-pencil'), 'Pencil tool', None) self.pencilAction.setShortcut(qt.QKeySequence(qt.Qt.Key_P)) self.pencilAction.setToolTip( 'Pencil tool: (Un)Mask using a pencil <b>P</b>') self.pencilAction.setCheckable(True) self.pencilAction.triggered.connect(self._activePencilMode) self.addAction(self.pencilAction) self.drawActionGroup = qt.QActionGroup(self) self.drawActionGroup.setExclusive(True) self.drawActionGroup.addAction(self.rectAction) self.drawActionGroup.addAction(self.ellipseAction) self.drawActionGroup.addAction(self.polygonAction) self.drawActionGroup.addAction(self.pencilAction) actions = (self.browseAction, self.rectAction, self.ellipseAction, self.polygonAction, self.pencilAction) drawButtons = [] for action in actions: btn = qt.QToolButton() btn.setDefaultAction(action) drawButtons.append(btn) container = self._hboxWidget(*drawButtons) layout.addWidget(container) # Mask/Unmask radio buttons maskRadioBtn = qt.QRadioButton('Mask') maskRadioBtn.setToolTip( 'Drawing masks with current level. Press <b>Ctrl</b> to unmask') maskRadioBtn.setChecked(True) unmaskRadioBtn = qt.QRadioButton('Unmask') unmaskRadioBtn.setToolTip( 'Drawing unmasks with current level. Press <b>Ctrl</b> to mask') self.maskStateGroup = qt.QButtonGroup() self.maskStateGroup.addButton(maskRadioBtn, 1) self.maskStateGroup.addButton(unmaskRadioBtn, 0) self.maskStateWidget = self._hboxWidget(maskRadioBtn, unmaskRadioBtn) layout.addWidget(self.maskStateWidget) self.maskStateWidget.setHidden(True) # Pencil settings self.pencilSetting = self._createPencilSettings(None) self.pencilSetting.setVisible(False) layout.addWidget(self.pencilSetting) layout.addStretch(1) drawGroup = qt.QGroupBox('Draw tools') drawGroup.setLayout(layout) return drawGroup
def _initMaskGroupBox(self): """Init general mask operation widgets""" # Mask level self.levelSpinBox = qt.QSpinBox() self.levelSpinBox.setRange(1, self._maxLevelNumber) self.levelSpinBox.setToolTip( 'Choose which mask level is edited.\n' 'A mask can have up to 255 non-overlapping levels.') self.levelSpinBox.valueChanged[int].connect(self._updateColors) self._levelWidget = self._hboxWidget(qt.QLabel('Mask level:'), self.levelSpinBox) # Transparency self._transparencyWidget = self._initTransparencyWidget() style = qt.QApplication.style() def getIcon(*identifiyers): for i in identifiyers: if isinstance(i, str): if qt.QIcon.hasThemeIcon(i): return qt.QIcon.fromTheme(i) elif isinstance(i, qt.QIcon): return i else: return style.standardIcon(i) return qt.QIcon() undoAction = qt.QAction(self) undoAction.setText('Undo') icon = getIcon("edit-undo", qt.QStyle.SP_ArrowBack) undoAction.setIcon(icon) undoAction.setShortcut(qt.QKeySequence.Undo) undoAction.setToolTip('Undo last mask change <b>%s</b>' % undoAction.shortcut().toString()) self._mask.sigUndoable.connect(undoAction.setEnabled) undoAction.triggered.connect(self._mask.undo) redoAction = qt.QAction(self) redoAction.setText('Redo') icon = getIcon("edit-redo", qt.QStyle.SP_ArrowForward) redoAction.setIcon(icon) redoAction.setShortcut(qt.QKeySequence.Redo) redoAction.setToolTip('Redo last undone mask change <b>%s</b>' % redoAction.shortcut().toString()) self._mask.sigRedoable.connect(redoAction.setEnabled) redoAction.triggered.connect(self._mask.redo) loadAction = qt.QAction(self) loadAction.setText('Load...') icon = icons.getQIcon("document-open") loadAction.setIcon(icon) loadAction.setToolTip('Load mask from file') loadAction.triggered.connect(self._loadMask) saveAction = qt.QAction(self) saveAction.setText('Save...') icon = icons.getQIcon("document-save") saveAction.setIcon(icon) saveAction.setToolTip('Save mask to file') saveAction.triggered.connect(self._saveMask) invertAction = qt.QAction(self) invertAction.setText('Invert') icon = icons.getQIcon("mask-invert") invertAction.setIcon(icon) invertAction.setShortcut(qt.Qt.CTRL + qt.Qt.Key_I) invertAction.setToolTip('Invert current mask <b>%s</b>' % invertAction.shortcut().toString()) invertAction.triggered.connect(self._handleInvertMask) clearAction = qt.QAction(self) clearAction.setText('Clear') icon = icons.getQIcon("mask-clear") clearAction.setIcon(icon) clearAction.setShortcut(qt.QKeySequence.Delete) clearAction.setToolTip('Clear current mask level <b>%s</b>' % clearAction.shortcut().toString()) clearAction.triggered.connect(self._handleClearMask) clearAllAction = qt.QAction(self) clearAllAction.setText('Clear all') icon = icons.getQIcon("mask-clear-all") clearAllAction.setIcon(icon) clearAllAction.setToolTip('Clear all mask levels') clearAllAction.triggered.connect(self.resetSelectionMask) # Buttons group margin1 = qt.QWidget(self) margin1.setMinimumWidth(6) margin2 = qt.QWidget(self) margin2.setMinimumWidth(6) actions = (loadAction, saveAction, margin1, undoAction, redoAction, margin2, invertAction, clearAction, clearAllAction) widgets = [] for action in actions: if isinstance(action, qt.QWidget): widgets.append(action) continue btn = qt.QToolButton() btn.setDefaultAction(action) widgets.append(btn) if action is clearAllAction: self._clearAllBtn = btn container = self._hboxWidget(*widgets) container.layout().setSpacing(1) layout = qt.QVBoxLayout() layout.addWidget(container) layout.addWidget(self._levelWidget) layout.addWidget(self._transparencyWidget) layout.addStretch(1) maskGroup = qt.QGroupBox('Mask') maskGroup.setLayout(layout) return maskGroup
def createTreeViewConfigurationPanel(self, parent, treeview): """Create a configuration panel to allow to play with widget states""" panel = qt.QWidget(parent) panel.setLayout(qt.QHBoxLayout()) content = qt.QGroupBox("Create HDF5", panel) content.setLayout(qt.QVBoxLayout()) panel.layout().addWidget(content) combo = qt.QComboBox() combo.addItem("Containing all types", get_hdf5_with_all_types) combo.addItem("Containing all links", get_hdf5_with_all_links) combo.addItem("Containing 1000 datasets", get_hdf5_with_1000_datasets) combo.addItem("Containing 10000 datasets", get_hdf5_with_10000_datasets) combo.addItem("Containing 100000 datasets", get_hdf5_with_100000_datasets) combo.addItem("Containing recursive links", get_hdf5_with_recursive_links) combo.addItem("Containing external recursive links", get_hdf5_with_external_recursive_links) combo.addItem("Containing NXdata groups", get_hdf5_with_nxdata) combo.activated.connect(self.__hdf5ComboChanged) content.layout().addWidget(combo) button = ThreadPoolPushButton(content, text="Create") button.setCallable(combo.itemData(combo.currentIndex())) button.succeeded.connect(self.__fileCreated) content.layout().addWidget(button) self.__hdf5Combo = combo self.__createHdf5Button = button asyncload = qt.QCheckBox("Async load", content) asyncload.setChecked(self.__asyncload) asyncload.toggled.connect( lambda: self.useAsyncLoad(asyncload.isChecked())) content.layout().addWidget(asyncload) content.layout().addStretch(1) content = qt.QGroupBox("Create EDF", panel) content.setLayout(qt.QVBoxLayout()) panel.layout().addWidget(content) combo = qt.QComboBox() combo.addItem("Containing all types", get_edf_with_all_types) combo.addItem("Containing 100000 datasets", get_edf_with_100000_frames) combo.activated.connect(self.__edfComboChanged) content.layout().addWidget(combo) button = ThreadPoolPushButton(content, text="Create") button.setCallable(combo.itemData(combo.currentIndex())) button.succeeded.connect(self.__fileCreated) content.layout().addWidget(button) self.__edfCombo = combo self.__createEdfButton = button content.layout().addStretch(1) option = qt.QGroupBox("Tree options", panel) option.setLayout(qt.QVBoxLayout()) panel.layout().addWidget(option) sorting = qt.QCheckBox("Enable sorting", option) sorting.setChecked( treeview.selectionMode() == qt.QAbstractItemView.MultiSelection) sorting.toggled.connect( lambda: treeview.setSortingEnabled(sorting.isChecked())) option.layout().addWidget(sorting) multiselection = qt.QCheckBox("Multi-selection", option) multiselection.setChecked( treeview.selectionMode() == qt.QAbstractItemView.MultiSelection) switch_selection = lambda: treeview.setSelectionMode( qt.QAbstractItemView.MultiSelection if multiselection.isChecked( ) else qt.QAbstractItemView.SingleSelection) multiselection.toggled.connect(switch_selection) option.layout().addWidget(multiselection) filedrop = qt.QCheckBox("Drop external file", option) filedrop.setChecked(treeview.findHdf5TreeModel().isFileDropEnabled()) filedrop.toggled.connect(lambda: treeview.findHdf5TreeModel(). setFileDropEnabled(filedrop.isChecked())) option.layout().addWidget(filedrop) filemove = qt.QCheckBox("Reorder files", option) filemove.setChecked(treeview.findHdf5TreeModel().isFileMoveEnabled()) filemove.toggled.connect(lambda: treeview.findHdf5TreeModel(). setFileMoveEnabled(filedrop.isChecked())) option.layout().addWidget(filemove) option.layout().addStretch(1) option = qt.QGroupBox("Header options", panel) option.setLayout(qt.QVBoxLayout()) panel.layout().addWidget(option) autosize = qt.QCheckBox("Auto-size headers", option) autosize.setChecked(treeview.header().hasAutoResizeColumns()) autosize.toggled.connect(lambda: treeview.header(). setAutoResizeColumns(autosize.isChecked())) option.layout().addWidget(autosize) columnpopup = qt.QCheckBox("Popup to hide/show columns", option) columnpopup.setChecked(treeview.header().hasHideColumnsPopup()) columnpopup.toggled.connect(lambda: treeview.header( ).setEnableHideColumnsPopup(columnpopup.isChecked())) option.layout().addWidget(columnpopup) define_columns = qt.QComboBox() define_columns.addItem("Default columns", treeview.findHdf5TreeModel().COLUMN_IDS) define_columns.addItem("Only name and Value", [ treeview.findHdf5TreeModel().NAME_COLUMN, treeview.findHdf5TreeModel().VALUE_COLUMN ]) define_columns.activated.connect(lambda index: treeview.header( ).setSections(define_columns.itemData(index))) option.layout().addWidget(define_columns) option.layout().addStretch(1) panel.layout().addStretch(1) return panel
def __init__(self, parent=None, title="Subtract strip background prior to estimation"): super(BackgroundPage, self).__init__(parent) self.setTitle(title) self.setCheckable(True) self.setToolTip( "The strip algorithm strips away peaks to compute the " + "background signal.\nAt each iteration, a sample is compared " + "to the average of the two samples at a given distance in both" + " directions,\n and if its value is higher than the average," "it is replaced by the average.") layout = qt.QGridLayout(self) self.setLayout(layout) for i, label_text in enumerate([ "Strip width (in samples)", "Number of iterations", "Strip threshold factor" ]): label = qt.QLabel(label_text) layout.addWidget(label, i, 0) self.stripWidthSpin = qt.QSpinBox(self) self.stripWidthSpin.setToolTip( "Width, in number of samples, of the strip operator") self.stripWidthSpin.setRange(1, 999999) layout.addWidget(self.stripWidthSpin, 0, 1) self.numIterationsSpin = qt.QSpinBox(self) self.numIterationsSpin.setToolTip( "Number of iterations of the strip algorithm") self.numIterationsSpin.setRange(1, 999999) layout.addWidget(self.numIterationsSpin, 1, 1) self.thresholdFactorEntry = qt.QLineEdit(self) self.thresholdFactorEntry.setToolTip( "Factor used by the strip algorithm to decide whether a sample" + "value should be stripped.\nThe value must be higher than the " + "average of the 2 samples at +- w times this factor.\n") self.thresholdFactorEntry.setValidator(qt.QDoubleValidator(self)) layout.addWidget(self.thresholdFactorEntry, 2, 1) self.smoothStripGB = qt.QGroupBox("Apply smoothing prior to strip", self) self.smoothStripGB.setCheckable(True) self.smoothStripGB.setToolTip( "Apply a smoothing before subtracting strip background" + " in fit and estimate processes") smoothlayout = qt.QHBoxLayout(self.smoothStripGB) label = qt.QLabel("Smoothing width (Savitsky-Golay)") smoothlayout.addWidget(label) self.smoothingWidthSpin = qt.QSpinBox(self) self.smoothingWidthSpin.setToolTip( "Width parameter for Savitsky-Golay smoothing (number of samples, must be odd)" ) self.smoothingWidthSpin.setRange(3, 101) self.smoothingWidthSpin.setSingleStep(2) smoothlayout.addWidget(self.smoothingWidthSpin) layout.addWidget(self.smoothStripGB, 3, 0, 1, 2) layout.setRowStretch(4, 1) self.setDefault()
def __init__(self, parent=None): super().__init__(parent) self.pv = loadPV() bigBoldFont = qt.QFont() bigBoldFont.setPointSize(9) bigBoldFont.setBold(True) self.engineLabel = qt.QLabel("State : ") self.engineLabel.setMinimumHeight(50) self.engineLabel.setMaximumHeight(50) self.engineStatus = qt.QLabel("EngineStatus") self.engineStatus.setFrameShape(qt.QFrame.Box) self.engineStatus.setFrameShadow(qt.QFrame.Sunken) self.engineStatus.setAlignment(qt.Qt.AlignCenter) self.engineStatus.setMinimumSize(qt.QSize(150, 50)) self.engineStatus.setMaximumSize(qt.QSize(150, 50)) self.abortButton = qt.QPushButton(self) self.abortButton.setText("Scan Abort") self.abortButton.setMinimumSize(qt.QSize(130, 50)) self.abortButton.setMaximumSize(qt.QSize(115, 50)) # high limit for scaler counts limit_hi = 900000 self.I0_rbv = CounterRbvLabel(pv=self.pv['Scaler']['I0_counter_cal'], scaler_pv=self.pv['Scaler']['scaler'], limit_hi=limit_hi) self.It_rbv = CounterRbvLabel(pv=self.pv['Scaler']['It_counter_cal'], scaler_pv=self.pv['Scaler']['scaler'], limit_hi=limit_hi) self.If_rbv = CounterRbvLabel(pv=self.pv['Scaler']['If_counter_cal'], scaler_pv=self.pv['Scaler']['scaler'], limit_hi=limit_hi) self.Ir_rbv = CounterRbvLabel(pv=self.pv['Scaler']['Ir_counter_cal'], scaler_pv=self.pv['Scaler']['scaler'], limit_hi=limit_hi) self.theta_angle_label = EpicsValueLabel( self.pv['DCM']['mono_theta'] + '.RBV', moving_pv=self.pv['DCM']['mono_theta_dmov']) self.theta_angle_label.setMinimumSize(qt.QSize(130, 30)) self.theta_angle_label.setMaximumSize(qt.QSize(130, 30)) self.theta_energy_label = EpicsValueLabel( self.pv['DCM']['mono_theta'] + '.RBV', moving_pv=self.pv['DCM']['mono_theta_dmov'], convert=angle_to_energy) self.theta_energy_label.setMinimumSize(qt.QSize(130, 30)) self.theta_energy_label.setMaximumSize(qt.QSize(130, 30)) self.life_time_label = EpicsValueLabel(self.pv['Beam']['LifeTime'], precision=2, convert=lambda x: x / 3600.) self.life_time_label.setMinimumSize(qt.QSize(100, 30)) self.life_time_label.setFrameShape(qt.QFrame.Panel) self.life_time_label.setFrameShadow(qt.QFrame.Sunken) self.life_time_label.setAlignment(qt.Qt.AlignCenter) self.topup_label = EpicsValueLabel(self.pv['Beam']['TopUpCount'], precision=2) self.topup_label.setMinimumSize(qt.QSize(100, 30)) self.topup_label.setFrameShape(qt.QFrame.Panel) self.topup_label.setFrameShadow(qt.QFrame.Sunken) self.topup_label.setAlignment(qt.Qt.AlignCenter) self.beam_current_label = EpicsValueLabel(self.pv['Beam']['Current'], precision=2) self.beam_current_label.setMinimumSize(qt.QSize(100, 30)) self.beam_current_label.setMaximumSize(qt.QSize(100, 30)) self.beam_current_label.setFrameShape(qt.QFrame.Panel) self.beam_current_label.setFrameShadow(qt.QFrame.Sunken) self.beam_current_label.setAlignment(qt.Qt.AlignCenter) self.num_of_steps_label = qt.QLabel("not conn.") self.num_of_steps_label.setMinimumSize(qt.QSize(100, 30)) self.num_of_steps_label.setMaximumSize(qt.QSize(100, 30)) self.num_of_steps_label.setFrameShape(qt.QFrame.Panel) self.num_of_steps_label.setFrameShadow(qt.QFrame.Sunken) self.num_of_steps_label.setAlignment(qt.Qt.AlignCenter) self.scan_point_label = qt.QLabel("not conn.") self.scan_point_label.setMinimumSize(qt.QSize(90, 30)) self.scan_point_label.setMaximumSize(qt.QSize(90, 30)) self.scan_point_label.setFrameShape(qt.QFrame.Panel) self.scan_point_label.setFrameShadow(qt.QFrame.Sunken) self.scan_point_label.setAlignment(qt.Qt.AlignCenter) self.scanInfoLoopTimeLabel = qt.QLabel('LoopTime : ') self.loop_time_label = qt.QLabel("not conn.") self.loop_time_label.setMinimumSize(qt.QSize(90, 30)) self.loop_time_label.setMaximumSize(qt.QSize(90, 30)) self.loop_time_label.setFrameShape(qt.QFrame.Panel) self.loop_time_label.setFrameShadow(qt.QFrame.Sunken) self.loop_time_label.setAlignment(qt.Qt.AlignCenter) self.num_of_history_spin_box = qt.QDoubleSpinBox(self) self.num_of_history_spin_box.setMinimumSize(qt.QSize(220, 30)) self.num_of_history_spin_box.setMaximumSize(qt.QSize(220, 30)) self.num_of_history_spin_box.setAlignment(qt.Qt.AlignCenter) self.num_of_history_spin_box.setDecimals(0) self.num_of_history_spin_box.setMinimum(1.0) self.num_of_history_spin_box.setMaximum(10.0) self.num_of_history_spin_box.setSingleStep(1.0) self.num_of_history_spin_box.setProperty("value", 1.0) self.x_axis_type_combo_box = qt.QComboBox(self) self.x_axis_type_combo_box.setMinimumSize(qt.QSize(220, 30)) self.x_axis_type_combo_box.setMaximumSize(qt.QSize(220, 30)) self.x_axis_type_combo_box.addItem("") self.x_axis_type_combo_box.addItem("") self.x_axis_type_combo_box.setItemText(0, "Delta(E-E0)") self.x_axis_type_combo_box.setItemText(1, "Energy(eV)") self.y_axis_type_combo_box = qt.QComboBox(self) self.y_axis_type_combo_box.setMinimumSize(qt.QSize(130, 30)) self.y_axis_type_combo_box.setMaximumSize(qt.QSize(130, 30)) self.y_axis_type_combo_box.addItem("") self.y_axis_type_combo_box.addItem("") self.y_axis_type_combo_box.addItem("") self.y_axis_type_combo_box.addItem("") self.y_axis_type_combo_box.addItem("") self.y_axis_type_combo_box.addItem("") self.y_axis_type_combo_box.addItem("") self.y_axis_type_combo_box.setItemText(0, "Transmittance") self.y_axis_type_combo_box.setItemText(1, "Fluorescence") self.y_axis_type_combo_box.setItemText(2, "Reference") self.y_axis_type_combo_box.setItemText(3, "View I0(1) Only") self.y_axis_type_combo_box.setItemText(4, "View IT(2) Only") self.y_axis_type_combo_box.setItemText(5, "View IF(3) Only") self.y_axis_type_combo_box.setItemText(6, "View IR(4) Only") self.derivativeCB = qt.QCheckBox(self) self.derivativeCB.setText('deriv.') main_panel = qt.QWidget(self) main_panel.setLayout(qt.QHBoxLayout()) self.setCentralWidget(main_panel) REWidget = qt.QWidget(self) REWidget.setLayout(qt.QFormLayout()) REWidget.layout().setLabelAlignment(qt.Qt.AlignRight) REWidget.layout().setFormAlignment(qt.Qt.AlignBottom) REWidget.layout().setContentsMargins(0, 0, 0, 0) REWidget.layout().addWidget(self.engineStatus) REWidget.layout().addWidget(self.abortButton) REWidget.layout().addRow( self.engineLabel, addWidgets([self.engineStatus, self.abortButton])) counterGB = qt.QGroupBox("Counters", main_panel) counterGB.setLayout(qt.QHBoxLayout()) counterGB.layout().setSpacing(20) counterGB.layout().addWidget(addLabelWidgetVert('I0', self.I0_rbv)) counterGB.layout().addWidget(addLabelWidgetVert('It', self.It_rbv)) counterGB.layout().addWidget(addLabelWidgetVert('Ir', self.Ir_rbv)) counterGB.layout().addWidget(addLabelWidgetVert('If', self.If_rbv)) dcmGB = qt.QGroupBox("Monochromator", main_panel) dcmGB.setLayout(qt.QFormLayout()) dcmGB.layout().setLabelAlignment(qt.Qt.AlignRight) dcmGB.layout().addRow('Angle [Deg.] : ', self.theta_angle_label) dcmGB.layout().addRow('Energy [eV]: ', self.theta_energy_label) beamGB = qt.QGroupBox("Beam", main_panel) beamGB.setLayout(qt.QFormLayout()) beamGB.layout().setLabelAlignment(qt.Qt.AlignRight) beamGB.layout().addRow('Life Time [hours] : ', self.life_time_label) beamGB.layout().addRow('TopUp Count [sec.] : ', self.topup_label) beamGB.layout().addRow('Current [mA] : ', self.beam_current_label) scanInfoGB = qt.QGroupBox("Scan Info", main_panel) scanInfoGB.setLayout(qt.QFormLayout()) scanInfoGB.layout().setLabelAlignment(qt.Qt.AlignRight) scanInfoGB.layout().addRow('NoOfSteps : ', self.num_of_steps_label) scanInfoGB.layout().addRow('ScanPoint : ', self.scan_point_label) scanInfoGB.layout().addRow(self.scanInfoLoopTimeLabel, self.loop_time_label) plotControlGB = qt.QGroupBox("Plot Control", main_panel) plotControlGB.setLayout(qt.QFormLayout()) plotControlGB.layout().setLabelAlignment(qt.Qt.AlignRight) plotControlGB.layout().addRow('# Of History : ', self.num_of_history_spin_box) plotControlGB.layout().addRow('X-axis type : ', self.x_axis_type_combo_box) plotControlGB.layout().addRow( 'Y-axis type : ', addWidgets([self.y_axis_type_combo_box, self.derivativeCB])) main_panel.layout().addWidget(addStretchWidget(REWidget)) main_panel.layout().addStretch(1) main_panel.layout().addWidget(addStretchWidget(dcmGB)) main_panel.layout().addWidget(addStretchWidget(counterGB)) main_panel.layout().addWidget(addStretchWidget(beamGB)) main_panel.layout().addWidget(addStretchWidget(scanInfoGB)) main_panel.layout().addWidget(addStretchWidget(plotControlGB))
def _initThresholdGroupBox(self): """Init thresholding widgets""" layout = qt.QVBoxLayout() # Thresholing self.belowThresholdAction = qt.QAction( icons.getQIcon('plot-roi-below'), 'Mask below threshold', None) self.belowThresholdAction.setToolTip( 'Mask image where values are below given threshold') self.belowThresholdAction.setCheckable(True) self.belowThresholdAction.triggered[bool].connect( self._belowThresholdActionTriggered) self.betweenThresholdAction = qt.QAction( icons.getQIcon('plot-roi-between'), 'Mask within range', None) self.betweenThresholdAction.setToolTip( 'Mask image where values are within given range') self.betweenThresholdAction.setCheckable(True) self.betweenThresholdAction.triggered[bool].connect( self._betweenThresholdActionTriggered) self.aboveThresholdAction = qt.QAction( icons.getQIcon('plot-roi-above'), 'Mask above threshold', None) self.aboveThresholdAction.setToolTip( 'Mask image where values are above given threshold') self.aboveThresholdAction.setCheckable(True) self.aboveThresholdAction.triggered[bool].connect( self._aboveThresholdActionTriggered) self.thresholdActionGroup = qt.QActionGroup(self) self.thresholdActionGroup.setExclusive(False) self.thresholdActionGroup.addAction(self.belowThresholdAction) self.thresholdActionGroup.addAction(self.betweenThresholdAction) self.thresholdActionGroup.addAction(self.aboveThresholdAction) self.thresholdActionGroup.triggered.connect( self._thresholdActionGroupTriggered) self.loadColormapRangeAction = qt.QAction( icons.getQIcon('view-refresh'), 'Set min-max from colormap', None) self.loadColormapRangeAction.setToolTip( 'Set min and max values from current colormap range') self.loadColormapRangeAction.setCheckable(False) self.loadColormapRangeAction.triggered.connect( self._loadRangeFromColormapTriggered) widgets = [] for action in self.thresholdActionGroup.actions(): btn = qt.QToolButton() btn.setDefaultAction(action) widgets.append(btn) spacer = qt.QWidget() spacer.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Preferred) widgets.append(spacer) loadColormapRangeBtn = qt.QToolButton() loadColormapRangeBtn.setDefaultAction(self.loadColormapRangeAction) widgets.append(loadColormapRangeBtn) container = self._hboxWidget(*widgets, stretch=False) layout.addWidget(container) form = qt.QFormLayout() self.minLineEdit = qt.QLineEdit() self.minLineEdit.setText('0') self.minLineEdit.setValidator(qt.QDoubleValidator(self)) self.minLineEdit.setEnabled(False) form.addRow('Min:', self.minLineEdit) self.maxLineEdit = qt.QLineEdit() self.maxLineEdit.setText('0') self.maxLineEdit.setValidator(qt.QDoubleValidator(self)) self.maxLineEdit.setEnabled(False) form.addRow('Max:', self.maxLineEdit) self.applyMaskBtn = qt.QPushButton('Apply mask') self.applyMaskBtn.clicked.connect(self._maskBtnClicked) self.applyMaskBtn.setEnabled(False) form.addRow(self.applyMaskBtn) self.maskNanBtn = qt.QPushButton('Mask not finite values') self.maskNanBtn.setToolTip('Mask Not a Number and infinite values') self.maskNanBtn.clicked.connect(self._maskNotFiniteBtnClicked) form.addRow(self.maskNanBtn) thresholdWidget = qt.QWidget() thresholdWidget.setLayout(form) layout.addWidget(thresholdWidget) layout.addStretch(1) self.thresholdGroup = qt.QGroupBox('Threshold') self.thresholdGroup.setLayout(layout) return self.thresholdGroup