def __init__(self, parent=None) -> None: qt.QWidget.__init__(self, parent) self.setLayout(qt.QGridLayout()) self._toggleButton = qt.QPushButton(parent=self) self.layout().addWidget(self._toggleButton, 0, 2, 1, 1) self._toggleButton.setSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Fixed) self._urlsTable = UrlList(parent=self) self.layout().addWidget(self._urlsTable, 1, 1, 1, 2) # set up self._setButtonIcon(show=True) # Signal / slot connection self._toggleButton.clicked.connect(self.toggleUrlSelectionTable) self._urlsTable.sigCurrentUrlChanged.connect(self._propagateSignal) # expose API self.setUrls = self._urlsTable.setUrls self.setUrl = self._urlsTable.setUrl self.currentItem = self._urlsTable.currentItem
from silx.gui import qt from silx.gui.console import IPythonWidget app = qt.QApplication([]) hello_button = qt.QPushButton("Hello World!", None) hello_button.show() console = IPythonWidget() console.show() console.pushVariables({"the_button": hello_button}) app.exec_()
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 _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 _initGui(self): qt.loadUi(pyFAI.utils.get_ui_file("calibration-geometry.ui"), self) icon = icons.getQIcon("pyfai:gui/icons/task-fit-geometry") self.setWindowIcon(icon) self.__calibrationState = CalibrationState(self) self.__calibration = None self.__peaksInvalidated = False self.__fitting = False self.__wavelengthInvalidated = False self.initNextStep() self.widgetShow.connect(self.__widgetShow) self.__plot = self.__createPlot() self.__plot.setObjectName("plot-fit") self.__plot.sigMouseMove.connect(self.__mouseMoved) self.__plot.sigMouseLeave.connect(self.__mouseLeft) self.__plot.setCalibrationState(self.__calibrationState) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) self.__defaultConstraints = GeometryConstraintsModel() userAngleUnit = CalibrationContext.instance().getAngleUnit() userLengthUnit = CalibrationContext.instance().getLengthUnit() userWavelengthUnit = CalibrationContext.instance().getWavelengthUnit() layout = qt.QGridLayout(self._settings) self.__wavelength = FitParamView(self, "Wavelength", units.Unit.METER_WL, userWavelengthUnit) self.addParameterToLayout(layout, self.__wavelength) layout = qt.QGridLayout(self._geometry) self.__distance = FitParamView(self, "Distance", units.Unit.METER, userLengthUnit) self.__poni1 = FitParamView(self, "PONI1", units.Unit.METER, userLengthUnit) self.__poni2 = FitParamView(self, "PONI2", units.Unit.METER, userLengthUnit) self.__rotation1 = FitParamView(self, "Rotation 1", units.Unit.RADIAN, userAngleUnit) self.__rotation2 = FitParamView(self, "Rotation 2", units.Unit.RADIAN, userAngleUnit) self.__rotation3 = FitParamView(self, "Rotation 3", units.Unit.RADIAN, userAngleUnit) self.__wavelength.sigValueAccepted.connect(self.__geometryCustomed) self.__distance.sigValueAccepted.connect(self.__geometryCustomed) self.__poni1.sigValueAccepted.connect(self.__geometryCustomed) self.__poni2.sigValueAccepted.connect(self.__geometryCustomed) self.__rotation1.sigValueAccepted.connect(self.__geometryCustomed) self.__rotation2.sigValueAccepted.connect(self.__geometryCustomed) self.__rotation3.sigValueAccepted.connect(self.__geometryCustomed) self.__distance.setDefaultConstraintsModel( self.__defaultConstraints.distance()) self.__wavelength.setDefaultConstraintsModel( self.__defaultConstraints.wavelength()) self.__poni1.setDefaultConstraintsModel( self.__defaultConstraints.poni1()) self.__poni2.setDefaultConstraintsModel( self.__defaultConstraints.poni2()) self.__rotation1.setDefaultConstraintsModel( self.__defaultConstraints.rotation1()) self.__rotation2.setDefaultConstraintsModel( self.__defaultConstraints.rotation2()) self.__rotation3.setDefaultConstraintsModel( self.__defaultConstraints.rotation3()) self.addParameterToLayout(layout, self.__distance) self.addParameterToLayout(layout, self.__poni1) self.addParameterToLayout(layout, self.__poni2) self.addParameterToLayout(layout, self.__rotation1) self.addParameterToLayout(layout, self.__rotation2) self.addParameterToLayout(layout, self.__rotation3) self._fitButton.clicked.connect(self.__fitGeometryLater) self._fitButton.setDisabledWhenWaiting(True) self._resetButton.clicked.connect(self.__resetGeometryLater) self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot) constraintLayout = qt.QHBoxLayout() defaultConstraintsButton = qt.QPushButton("Default contraints", self) defaultConstraintsButton.setToolTip( "Remove all the custom constraints.") saxsConstraintsButton = qt.QPushButton("SAXS contraints", self) saxsConstraintsButton.setToolTip("Force all the rotations to zero.") constraintLayout.addWidget(defaultConstraintsButton) constraintLayout.addWidget(saxsConstraintsButton) layout.addLayout(constraintLayout, layout.rowCount(), 0, 1, -1) defaultConstraintsButton.clicked.connect(self.__setDefaultConstraints) saxsConstraintsButton.clicked.connect(self.__setSaxsConstraints) self._geometryHistoryCombo.activated.connect( self.__geometryPickedFromHistory) self._geometryHistoryCombo.setAngleUnit(userAngleUnit) self.__calibrationState.changed.connect(self.__updateResidual) self.__updateResidual()
def __init__(self, xsocH5File, outQSpaceH5, qspaceDims=None, imageBinning=None, roi=None, entries=None, **kwargs): """ Widgets displaying informations about data to be converted to QSpace, and allowing the user to input some parameters. :param xsocH5File: name of the input XsocsH5 file. :param outQSpaceH5: name of the output hdf5 file :param qspaceDims: dimensions of the qspace volume :param imageBinning: binning to apply to the images before conversion. Default : (1, 1) :param roi: Roi in sample coordinates (xMin, xMax, yMin, yMax) :param entries: a list of entry names to convert to qspace. If None, all entries found in the xsocsH5File will be used. :param kwargs: """ super(QSpaceWidget, self).__init__(**kwargs) self.__status = QSpaceWidget.StatusInit xsocsH5 = XsocsH5(xsocH5File) # checking entries if entries is None: entries = xsocsH5.entries() elif len(entries) == 0: raise ValueError('At least one entry must be selected.') else: diff = set(entries) - set(xsocsH5.entries()) if len(diff) > 0: raise ValueError('The following entries were not found in ' 'the input file :\n - {0}' ''.format('\n -'.join(diff))) self.__params = { 'roi': roi, 'xsocsH5_f': xsocH5File, 'qspaceH5_f': outQSpaceH5 } topLayout = Qt.QGridLayout(self) # ATTENTION : this is done to allow the stretch # of the QTableWidget containing the scans info topLayout.setColumnStretch(1, 1) # ################ # input QGroupBox # ################ inputGbx = GroupBox("Input") layout = Qt.QHBoxLayout(inputGbx) topLayout.addWidget(inputGbx, 0, 0, 1, 2) # data HDF5 file input lab = Qt.QLabel('XsocsH5 file :') xsocsFileEdit = StyledLineEdit(nChar=50, readOnly=True) xsocsFileEdit.setText(xsocH5File) layout.addWidget(lab, stretch=0, alignment=Qt.Qt.AlignLeft) layout.addWidget(xsocsFileEdit, stretch=0, alignment=Qt.Qt.AlignLeft) layout.addStretch() # ################ # Scans # ################ scansGbx = GroupBox("Scans") topLayout.addWidget(scansGbx, 1, 1, 2, 1) topLayout.setRowStretch(2, 1000) grpLayout = Qt.QVBoxLayout(scansGbx) infoLayout = Qt.QGridLayout() grpLayout.addLayout(infoLayout) line = 0 label = Qt.QLabel('# Roi :') self.__roiXMinEdit = xMinText = StyledLineEdit(nChar=5, readOnly=True) self.__roiXMaxEdit = xMaxText = StyledLineEdit(nChar=5, readOnly=True) self.__roiYMinEdit = yMinText = StyledLineEdit(nChar=5, readOnly=True) self.__roiYMaxEdit = yMaxText = StyledLineEdit(nChar=5, readOnly=True) roiLayout = Qt.QHBoxLayout() roiLayout.addWidget(xMinText) roiLayout.addWidget(xMaxText) roiLayout.addWidget(yMinText) roiLayout.addWidget(yMaxText) infoLayout.addWidget(label, line, 0) infoLayout.addLayout(roiLayout, line, 1, alignment=Qt.Qt.AlignLeft) line += 1 label = Qt.QLabel('# points :') self.__nImgLabel = nImgLabel = StyledLineEdit(nChar=16, readOnly=True) nImgLayout = Qt.QHBoxLayout() infoLayout.addWidget(label, line, 0) infoLayout.addLayout(nImgLayout, line, 1, alignment=Qt.Qt.AlignLeft) nImgLayout.addWidget(nImgLabel) nImgLayout.addWidget(Qt.QLabel(' (roi / total)')) line += 1 label = Qt.QLabel(u'# {0} :'.format(_ETA_LOWER)) self.__nAnglesLabel = nAnglesLabel = StyledLineEdit(nChar=5, readOnly=True) infoLayout.addWidget(label, line, 0) infoLayout.addWidget(nAnglesLabel, line, 1, alignment=Qt.Qt.AlignLeft) infoLayout.setColumnStretch(2, 1) self.__scansTable = scansTable = Qt.QTableWidget(0, 2) scansTable.verticalHeader().hide() grpLayout.addWidget(scansTable, alignment=Qt.Qt.AlignLeft) # ################ # conversion params # ################ convGbx = GroupBox("Conversion parameters") grpLayout = Qt.QVBoxLayout(convGbx) topLayout.addWidget(convGbx, 1, 0, alignment=Qt.Qt.AlignTop) self.__paramsWid = paramsWid = ConversionParamsWidget() grpLayout.addWidget(paramsWid) # ################ # output # ################ outputGbx = GroupBox("Output") layout = Qt.QHBoxLayout(outputGbx) topLayout.addWidget(outputGbx, 3, 0, 1, 2) lab = Qt.QLabel('Output :') outputFileEdit = StyledLineEdit(nChar=50, readOnly=True) outputFileEdit.setText(outQSpaceH5) layout.addWidget(lab, stretch=0, alignment=Qt.Qt.AlignLeft) layout.addWidget(outputFileEdit, stretch=0, alignment=Qt.Qt.AlignLeft) layout.addStretch() # ################ # buttons # ################ self.__converBn = convertBn = Qt.QPushButton('Convert') cancelBn = Qt.QPushButton('Cancel') hLayout = Qt.QHBoxLayout() topLayout.addLayout(hLayout, 4, 0, 1, 2, Qt.Qt.AlignHCenter | Qt.Qt.AlignTop) hLayout.addWidget(convertBn) hLayout.addWidget(cancelBn) # ################# # setting initial state # ################# self.__converter = QSpaceConverter(xsocH5File, output_f=outQSpaceH5, qspace_dims=qspaceDims, img_binning=imageBinning, roi=roi, entries=entries) cancelBn.clicked.connect(self.close) convertBn.clicked.connect(self.__slotConvertBnClicked) self.__fillScansInfos()
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
def createOptions(self, layout): button = qt.QPushButton("Create a new dialog") button.clicked.connect(self.createColorDialog) layout.addWidget(button) layout.addSpacing(10) button = qt.QPushButton("Set editable") button.clicked.connect(self.setEditable) layout.addWidget(button) button = qt.QPushButton("Set non-editable") button.clicked.connect(self.setNonEditable) layout.addWidget(button) layout.addSpacing(10) button = qt.QPushButton("Set no colormap") button.clicked.connect(self.setNoColormap) layout.addWidget(button) button = qt.QPushButton("Set colormap 1") button.clicked.connect(self.setColormap1) layout.addWidget(button) button = qt.QPushButton("Set colormap 2") button.clicked.connect(self.setColormap2) layout.addWidget(button) button = qt.QPushButton("Create new colormap") button.clicked.connect(self.setNewColormap) layout.addWidget(button) layout.addSpacing(10) button = qt.QPushButton("Set no histogram") button.clicked.connect(self.setNoHistogram) layout.addWidget(button) button = qt.QPushButton("Set positive histogram") button.clicked.connect(self.setPositiveHistogram) layout.addWidget(button) button = qt.QPushButton("Set neg-pos histogram") button.clicked.connect(self.setNegPosHistogram) layout.addWidget(button) button = qt.QPushButton("Set negative histogram") button.clicked.connect(self.setNegativeHistogram) layout.addWidget(button) layout.addSpacing(10) button = qt.QPushButton("Set no range") button.clicked.connect(self.setNoRange) layout.addWidget(button) button = qt.QPushButton("Set positive range") button.clicked.connect(self.setPositiveRange) layout.addWidget(button) button = qt.QPushButton("Set neg-pos range") button.clicked.connect(self.setNegPosRange) layout.addWidget(button) button = qt.QPushButton("Set negative range") button.clicked.connect(self.setNegativeRange) layout.addWidget(button) layout.addSpacing(10) button = qt.QPushButton("Set no data") button.clicked.connect(self.setNoData) layout.addWidget(button) button = qt.QPushButton("Set shepp logan phantom") button.clicked.connect(self.setSheppLoganPhantom) layout.addWidget(button) button = qt.QPushButton("Set data with non finite") button.clicked.connect(self.setDataWithNonFinite) layout.addWidget(button) layout.addStretch()
def __init__(self, parent=None): super(MyPlotWindow, self).__init__(parent) # Create a PlotWidget self._plot = PlotWidget(parent=self) # Create a colorbar linked with the PlotWidget colorBar = ColorBarWidget(parent=self, plot=self._plot) # Make ColorBarWidget background white by changing its palette colorBar.setAutoFillBackground(True) palette = colorBar.palette() palette.setColor(qt.QPalette.Background, qt.Qt.white) palette.setColor(qt.QPalette.Window, qt.Qt.white) colorBar.setPalette(palette) options = qt.QWidget(self) layout = qt.QVBoxLayout(options) button = qt.QPushButton("Show image", self) button.clicked.connect(self.showImage) layout.addWidget(button) button = qt.QPushButton("Show scatter", self) button.clicked.connect(self.showScatter) layout.addWidget(button) button = qt.QPushButton("Show delaunay", self) button.clicked.connect(self.showDelaunay) layout.addWidget(button) layout.addStretch() # Combine the ColorBarWidget and the PlotWidget as # this QMainWindow's central widget gridLayout = qt.QGridLayout() gridLayout.setSpacing(0) gridLayout.setContentsMargins(0, 0, 0, 0) gridLayout.addWidget(options, 0, 0) gridLayout.addWidget(self._plot, 0, 1) gridLayout.addWidget(colorBar, 0, 2) gridLayout.setRowStretch(0, 1) gridLayout.setColumnStretch(1, 1) centralWidget = qt.QWidget(self) centralWidget.setLayout(gridLayout) self.setCentralWidget(centralWidget) # Add ready to use toolbar with zoom and pan interaction mode buttons interactionToolBar = tools.InteractiveModeToolBar(parent=self, plot=self._plot) self.addToolBar(interactionToolBar) # Add toolbar actions to activate keyboard shortcuts self.addActions(interactionToolBar.actions()) # Add a new toolbar toolBar = qt.QToolBar("Plot Tools", self) self.addToolBar(toolBar) # Add actions from silx.gui.plot.action to the toolbar resetZoomAction = actions.control.ResetZoomAction(parent=self, plot=self._plot) toolBar.addAction(resetZoomAction) # Add tool buttons from silx.gui.plot.PlotToolButtons aspectRatioButton = PlotToolButtons.AspectToolButton(parent=self, plot=self._plot) toolBar.addWidget(aspectRatioButton) # Add ready to use toolbar with copy, save and print buttons outputToolBar = tools.OutputToolBar(parent=self, plot=self._plot) self.addToolBar(outputToolBar) # Add toolbar actions to activate keyboard shortcuts self.addActions(outputToolBar.actions()) # Add limits tool bar from silx.gui.plot.PlotTools limitsToolBar = tools.LimitsToolBar(parent=self, plot=self._plot) self.addToolBar(qt.Qt.BottomToolBarArea, limitsToolBar)
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 __init__(self, qspaceFile, **kwargs): super(FitWidget, self).__init__(**kwargs) self.__qspaceH5 = qspaceH5 = QSpaceH5(qspaceFile) self.__progTimer = None self.__outputFile = None self.__nPeaks = 1 layout = Qt.QGridLayout(self) self.__roiWidget = roiWidget = Roi3DSelectorWidget() layout.addWidget(roiWidget) fileLayout = Qt.QHBoxLayout() self.__fileEdit = fileEdit = StyledLineEdit(nChar=20, readOnly=True) fileLayout.addWidget(Qt.QLabel('File :')) fileLayout.addWidget(fileEdit) layout.addLayout(fileLayout, 1, 0) fitLayout = Qt.QHBoxLayout() self.__fitTypeCb = fitTypeCb = Qt.QComboBox() fitTypeCb.addItems(list(FitWidget.FitTypes.keys())) fitTypeCb.setCurrentIndex(0) fitLayout.addWidget(Qt.QLabel('Fit :')) fitLayout.addWidget(fitTypeCb) fitTypeCb.currentIndexChanged[str].connect( self.__slotCurrentTextChanged) layout.addLayout(fitLayout, 2, 0, alignment=Qt.Qt.AlignLeft) self.__nPeaksSpinBox = spinbox = Qt.QSpinBox() # spinbox.setMinimum(1) # spinbox.setMaximum(20) # spinbox.setValue(self.__nPeaks) # spinbox.setToolTip('Max. number of expected peaks.') # spinbox.valueChanged.connect(self.__slotValueChanged) # fitLayout.addWidget(spinbox) # fitLayout.addWidget(Qt.QLabel('peak(s)')) runLayout = Qt.QHBoxLayout() self.__runButton = runButton = Qt.QPushButton('Run') runButton.setEnabled(False) runButton.clicked.connect(self.__slotRunClicked) runLayout.addWidget(runButton) self.__progBar = progBar = Qt.QProgressBar() runLayout.addWidget(progBar) layout.addLayout(runLayout, 3, 0, alignment=Qt.Qt.AlignCenter) self.__statusLabel = statusLabel = Qt.QLabel('Ready') statusLabel.setFrameStyle(Qt.QFrame.Panel | Qt.QFrame.Sunken) layout.addWidget(statusLabel, 4, 0) with qspaceH5: qx = qspaceH5.qx qy = qspaceH5.qy qz = qspaceH5.qz roiWidget.xSlider().setRange([qx[0], qx[-1]]) roiWidget.ySlider().setRange([qy[0], qy[-1]]) roiWidget.zSlider().setRange([qz[0], qz[-1]]) self.__sigFitDone.connect(self.__slotFitDone) layout.setRowStretch(layout.rowCount(), 1) layout.setColumnStretch(layout.columnCount(), 1)
def __init__(self, merger, **kwargs): super(_ScansSelectDialog, self).__init__(**kwargs) layout = Qt.QGridLayout(self) matched = merger.matched_ids selected = merger.selected_ids table_widget = Qt.QTableWidget(len(matched), self.COL_COUNT) table_widget.setHorizontalHeaderLabels([ '', 'ID', 'M0', 'start', 'end', 'step', 'M1', 'start', 'end', 'step', 'Image File' ]) def _sizeHint(self): width = ( sum([self.columnWidth(i) for i in range(self.columnCount())]) + self.verticalHeader().width() + 20) return Qt.QSize(width, self.height()) table_widget.sizeHint = MethodType(_sizeHint, table_widget) table_widget.minimumSize = MethodType(_sizeHint, table_widget) table_widget.maximumSize = MethodType(_sizeHint, table_widget) self.setSizePolicy( Qt.QSizePolicy(Qt.QSizePolicy.Fixed, Qt.QSizePolicy.Minimum)) for num, scan_id in enumerate(matched): command = merger.get_scan_command(scan_id) item = Qt.QTableWidgetItem() item.setFlags(Qt.Qt.ItemIsUserCheckable | Qt.Qt.ItemIsEditable | Qt.Qt.ItemIsSelectable | Qt.Qt.ItemIsEnabled) state = Qt.Qt.Checked if scan_id in selected else Qt.Qt.Unchecked item.setCheckState(state) table_widget.setItem(num, self.SEL_COL, item) def _add_col(value, col_idx): item = Qt.QTableWidgetItem(value) item.setFlags(item.flags() ^ Qt.Qt.ItemIsEditable) item.setTextAlignment(Qt.Qt.AlignRight) table_widget.setItem(num, col_idx, item) _add_col(str(scan_id), self.ID_COL) _add_col(command['motor_0'], self.M0_COL) _add_col(command['motor_0_start'], self.M0_START_COL) _add_col(command['motor_0_end'], self.M0_END_COL) _add_col(command['motor_0_steps'], self.M0_STEP_COL) _add_col(command['motor_1'], self.M1_COL) _add_col(command['motor_1_start'], self.M1_START_COL) _add_col(command['motor_1_end'], self.M1_END_COL) _add_col(command['motor_1_steps'], self.M1_STEP_COL) img_file = merger.get_scan_image(scan_id) item = Qt.QTableWidgetItem(os.path.basename(img_file)) item.setFlags(item.flags() ^ Qt.Qt.ItemIsEditable) item.setToolTip(img_file) table_widget.setItem(num, self.IMG_FILE_COL, item) table_widget.resizeColumnsToContents() table_widget.resizeRowsToContents() layout.addWidget(table_widget, 0, 0, Qt.Qt.AlignLeft) table_widget.setColumnHidden(self.M0_COL, True) table_widget.setColumnHidden(self.M0_START_COL, True) table_widget.setColumnHidden(self.M0_END_COL, True) table_widget.setColumnHidden(self.M0_STEP_COL, True) table_widget.setColumnHidden(self.M1_COL, True) table_widget.setColumnHidden(self.M1_START_COL, True) table_widget.setColumnHidden(self.M1_END_COL, True) table_widget.setColumnHidden(self.M1_STEP_COL, True) bnLayout = Qt.QGridLayout() layout.addLayout(bnLayout, 1, 0) selBn = Qt.QPushButton('Select') unselBn = Qt.QPushButton('Unselect') bnLayout.addWidget(selBn, 0, 0, Qt.Qt.AlignLeft) bnLayout.addWidget(unselBn, 0, 1, Qt.Qt.AlignLeft) selBn.clicked.connect(self.__selectClicked) unselBn.clicked.connect(self.__unselectClicked) bnLayout.setColumnStretch(2, 1) more_bn = FixedSizePushButon('More') bnLayout.addWidget(more_bn, 0, 3, Qt.Qt.AlignRight) bn_box = Qt.QDialogButtonBox(Qt.QDialogButtonBox.Ok | Qt.QDialogButtonBox.Cancel) bn_box.button(Qt.QDialogButtonBox.Ok).setText('Apply') layout.addWidget(bn_box, 2, 0) bn_box.accepted.connect(self.__onAccept) bn_box.rejected.connect(self.reject) more_bn.clicked.connect(self.__showMore) self.__table_widget = table_widget self.__more_bn = more_bn self.__merger = merger
def __init__(self, spec_file=None, img_dir=None, spec_version=1, output_dir=None, tmp_dir=None, **kwargs): super(MergeWidget, self).__init__(**kwargs) Qt.QGridLayout(self) # ################ # input QGroupBox # ################ if spec_file is not None: specFile = spec_file else: specFile = '' if img_dir is not None: imgDir = img_dir else: imgDir = '' if spec_version is not None: specVersion = spec_version else: specVersion = self._defaultVersion if output_dir is not None: outputDir = output_dir else: outputDir = '' # parameters self.__input = { 'specfile': specFile, 'imgdir': imgDir, 'version': specVersion, 'padding': None, 'offset': None } self.__output = {'outdir': outputDir, 'prefix': ''} inputGbx = GroupBox("Input") layout = Qt.QGridLayout(inputGbx) self.layout().addWidget(inputGbx, 0, 0, Qt.Qt.AlignTop) first_col = 0 file_bn_col = 4 last_col = file_bn_col + 1 spec_row = 0 img_path_row = 1 version_row = 2 apply_bn_row = 3 # spec file input specFileChooser = FileChooser(fileMode=Qt.QFileDialog.ExistingFile, noLabel=True) specFileChooser.lineEdit.setText(specFile) specFileChooser.sigSelectionChanged.connect(self.__slotSpecFileChanged) layout.addWidget(Qt.QLabel('Spec file :'), spec_row, 0) layout.addWidget(specFileChooser, spec_row, 1) # image folder input imgDirChooser = FileChooser(fileMode=Qt.QFileDialog.Directory, noLabel=True) imgDirChooser.lineEdit.setText(imgDir) imgDirChooser.sigSelectionChanged.connect(self.__slotImgDirChanged) layout.addWidget(Qt.QLabel('Img dir. :'), img_path_row, 0) layout.addWidget(imgDirChooser, img_path_row, 1) # version selection optionLayout = Qt.QHBoxLayout() optionLayout.addStretch(1) lab = Qt.QLabel('Version :') self.__versionCBx = versionCBx = Qt.QComboBox() for version in range(len(self._versions)): versionCBx.addItem(str(version)) versionCBx.addItem('') optionLayout.addWidget(lab, Qt.Qt.AlignLeft) optionLayout.addWidget(versionCBx, Qt.Qt.AlignLeft) # filename padding for the nextNr counter self.__padSpinBox = padSpinBox = Qt.QSpinBox() optionLayout.addWidget(_vLine()) optionLayout.addWidget(Qt.QLabel('nextNr padding:')) optionLayout.addWidget(padSpinBox, Qt.Qt.AlignLeft) padSpinBox.valueChanged[int].connect(self.__slotPaddingValueChanged) # filename offset for the nextNr counter self.__nextNrSpinBox = nextNrSpinBox = Qt.QSpinBox() nextNrSpinBox.setMinimum(-100) nextNrSpinBox.setMaximum(100) optionLayout.addWidget(_vLine()) optionLayout.addWidget(Qt.QLabel('nextNr offset:')) optionLayout.addWidget(nextNrSpinBox, Qt.Qt.AlignLeft) nextNrSpinBox.valueChanged[int].connect(self.__slotNextNrValueChanged) optionLayout.addStretch(100) layout.addLayout(optionLayout, version_row, 0, 1, layout.columnCount(), Qt.Qt.AlignLeft) # last row : apply button self.__parseBn = parseBn = FixedSizePushButon('Parse file') parseBn.clicked.connect(self.__slotParseBnClicked, Qt.Qt.QueuedConnection) layout.addWidget(parseBn, apply_bn_row, 0, 1, last_col - first_col, Qt.Qt.AlignHCenter) # ################ # scans + edf QGroupBox # ################ self.__scansGbx = scansGbx = GroupBox("Spec + EDF") grpLayout = Qt.QHBoxLayout(scansGbx) self.layout().addWidget(scansGbx, 1, 0, Qt.Qt.AlignLeft | Qt.Qt.AlignTop) # =========== # valid scans # =========== scanLayout = Qt.QGridLayout() grpLayout.addLayout(scanLayout) hLayout = Qt.QHBoxLayout() label = Qt.QLabel('<span style=" font-weight:600; color:#00916a;">' 'Matched scans</span>') label.setTextFormat(Qt.Qt.RichText) editScansBn = FixedSizePushButon('Edit') editScansBn.clicked.connect(self.__slotEditScansClicked) hLayout.addWidget(label) hLayout.addWidget(editScansBn) scanLayout.addLayout(hLayout, 0, 0, 1, 2) label = Qt.QLabel('Total :') self.__totalScansEdit = totalScansEdit = Qt.QLineEdit('0') totalScansEdit.setReadOnly(True) fm = totalScansEdit.fontMetrics() width = (fm.boundingRect('0123456').width() + fm.boundingRect('00').width()) totalScansEdit.setMaximumWidth(width) totalScansEdit.setAlignment(Qt.Qt.AlignRight) scanLayout.addWidget(label, 1, 0, Qt.Qt.AlignLeft) scanLayout.addWidget(totalScansEdit, 1, 1, Qt.Qt.AlignLeft) # ==== label = Qt.QLabel('Selected :') self.__selectedScansEdit = selectedScansEdit = Qt.QLineEdit('0') selectedScansEdit.setReadOnly(True) fm = selectedScansEdit.fontMetrics() width = (fm.boundingRect('0123456').width() + fm.boundingRect('00').width()) selectedScansEdit.setMaximumWidth(width) selectedScansEdit.setAlignment(Qt.Qt.AlignRight) scanLayout.addWidget(label, 2, 0, Qt.Qt.AlignLeft) scanLayout.addWidget(selectedScansEdit, 2, 1, Qt.Qt.AlignLeft) # === grpLayout.addWidget(_vLine()) # =========== # "other" scans # =========== scanLayout = Qt.QGridLayout() grpLayout.addLayout(scanLayout) hLayout = Qt.QHBoxLayout() label = Qt.QLabel('<span style=" font-weight:600; color:#ff6600;">' 'Other scans</span>') otherScansBn = FixedSizePushButon('View') otherScansBn.clicked.connect(self.__slotOtherScansClicked) hLayout.addWidget(label) hLayout.addWidget(otherScansBn) scanLayout.addLayout(hLayout, 0, 0, 1, 2) label = Qt.QLabel('No match :') self.__noMatchScansEdit = noMatchScansEdit = Qt.QLineEdit('0') noMatchScansEdit.setReadOnly(True) fm = noMatchScansEdit.fontMetrics() width = (fm.boundingRect('0123456').width() + fm.boundingRect('00').width()) noMatchScansEdit.setMaximumWidth(width) noMatchScansEdit.setAlignment(Qt.Qt.AlignRight) scanLayout.addWidget(label, 1, 0, Qt.Qt.AlignLeft) scanLayout.addWidget(noMatchScansEdit, 1, 1, Qt.Qt.AlignLeft) # ==== label = Qt.QLabel('No img info :') self.__noImgInfoEdit = noImgInfoEdit = Qt.QLineEdit('0') noImgInfoEdit.setReadOnly(True) fm = noImgInfoEdit.fontMetrics() width = (fm.boundingRect('0123456').width() + fm.boundingRect('00').width()) noImgInfoEdit.setMaximumWidth(width) noImgInfoEdit.setAlignment(Qt.Qt.AlignRight) scanLayout.addWidget(label, 2, 0, Qt.Qt.AlignLeft) scanLayout.addWidget(noImgInfoEdit, 2, 1, Qt.Qt.AlignLeft) # === grpLayout.addWidget(_vLine()) # ################ # parameters # ################ self.__acqParamsGbx = acqParamsGbx = GroupBox("Acq. Parameters") grpLayout = Qt.QVBoxLayout(acqParamsGbx) self.__acqParamWid = acqParamWid = AcqParamsWidget() self.layout().addWidget(acqParamsGbx, 2, 0, Qt.Qt.AlignLeft | Qt.Qt.AlignTop) grpLayout.addWidget(acqParamWid) # ################ # output options # ################ self.__outputGbx = outputGbx = GroupBox("Output") layout = Qt.QGridLayout(outputGbx) self.layout().addWidget(outputGbx, 3, 0, Qt.Qt.AlignTop) # =========== # master # =========== lab = Qt.QLabel('Prefix :') self.__prefixEdit = prefixEdit = StyledLineEdit(nChar=20) prefixEdit.textChanged.connect(self.__slotPrefixChanged) hLayout = Qt.QHBoxLayout() layout.addLayout(hLayout, 0, 1, Qt.Qt.AlignLeft) resetPrefixBn = Qt.QToolButton() icon = Qt.qApp.style().standardIcon(Qt.QStyle.SP_BrowserReload) resetPrefixBn.setIcon(icon) resetPrefixBn.clicked.connect(self.__slotResetPrefixClicked) layout.addWidget(lab, 0, 0, Qt.Qt.AlignLeft) sp = prefixEdit.sizePolicy() sp.setHorizontalPolicy(Qt.QSizePolicy.Maximum) prefixEdit.setSizePolicy(sp) hLayout.addWidget(prefixEdit, Qt.Qt.AlignLeft) hLayout.addWidget(resetPrefixBn, Qt.Qt.AlignLeft) # =========== # output folder # =========== outDirChooser = FileChooser(fileMode=Qt.QFileDialog.Directory, noLabel=True) outDirChooser.lineEdit.setText(outputDir) outDirChooser.sigSelectionChanged.connect(self.__slotOutDirChanged) layout.addWidget(Qt.QLabel('Output directory :'), 1, 0) layout.addWidget(outDirChooser, 1, 1) # ################ # merge button # ################ self.__mergeBn = mergeBn = Qt.QPushButton('Merge') cancelBn = Qt.QPushButton('Cancel') hLayout = Qt.QHBoxLayout() self.layout().addLayout(hLayout, 4, 0, 1, 1, Qt.Qt.AlignHCenter | Qt.Qt.AlignTop) hLayout.addWidget(mergeBn) hLayout.addWidget(cancelBn) mergeBn.clicked.connect(self.__slotMergeBnClicked) cancelBn.clicked.connect(self.reject) # ################# # setting initial state # ################# # scansGbx.setEnabled(False) # acqParamsGbx.setEnabled(False) # outputGbx.setEnabled(False) # mergeBn.setEnabled(False) parseBn.setEnabled(False) self.__merger = None self.__parser = None self.info_wid = None if tmp_dir is None: tmp_dir, delete_tmp, q_tmp_dir = _create_tmp_dir() else: delete_tmp = False q_tmp_dir = None self.__tmp_root = tmp_dir self.__delete_tmp_root = delete_tmp self.__q_tmp_dir = q_tmp_dir tmp_dir = os.path.join(self.__tmp_root, 'xsocs_merge') if not os.path.exists(tmp_dir): os.makedirs(tmp_dir) self.__tmp_dir_merge = tmp_dir print('Using temporary folder : {0}.'.format(tmp_dir)) self.__widgetIsSetup = False self.__xsocs_h5 = None versionCBx.setCurrentIndex(spec_version) self.__slotVersionChanged(spec_version) versionCBx.currentIndexChanged[int].connect(self.__slotVersionChanged) self.__resetState() self.__sigParsed.connect(self.__slotParsed, Qt.Qt.QueuedConnection)