def __init__(self, parent=None, title="Set constraints"): super(ConstraintsPage, self).__init__(parent) self.setTitle(title) self.setToolTip("Disable 'Set constraints' to remove all " + "constraints on all fit parameters") self.setCheckable(True) layout = qt.QVBoxLayout(self) self.setLayout(layout) self.positiveHeightCB = qt.QCheckBox("Force positive height/area", self) self.positiveHeightCB.setToolTip("Fit must find positive peaks") layout.addWidget(self.positiveHeightCB) self.positionInIntervalCB = qt.QCheckBox("Force position in interval", self) self.positionInIntervalCB.setToolTip( "Fit must position peak within X limits") layout.addWidget(self.positionInIntervalCB) self.positiveFwhmCB = qt.QCheckBox("Force positive FWHM", self) self.positiveFwhmCB.setToolTip("Fit must find a positive FWHM") layout.addWidget(self.positiveFwhmCB) self.sameFwhmCB = qt.QCheckBox("Force same FWHM for all peaks", self) self.sameFwhmCB.setToolTip("Fit must find same FWHM for all peaks") layout.addWidget(self.sameFwhmCB) self.quotedEtaCB = qt.QCheckBox("Force Eta between 0 and 1", self) self.quotedEtaCB.setToolTip( "Fit must find Eta between 0 and 1 for pseudo-Voigt function") layout.addWidget(self.quotedEtaCB) layout.addStretch() self.setDefault()
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 fillSplitterFiles(self): splitterInner = qt.QWidget(self.splitterFiles) labelFilter = qt.QLabel('file filter') self.editFileFilter = qt.QLineEdit() self.editFileFilter.returnPressed.connect(self.setFileFilter) if hasattr(self.node, 'fileNameFilters'): self.editFileFilter.setText(', '.join(self.node.fileNameFilters)) self.files = FileTreeView(self.node) # self.files.doubleClicked.connect(self.loadFiles) self.files.model().directoryLoaded.connect(self._directoryIsLoaded) self.filesAutoAddCB = qt.QCheckBox("auto append fresh file TODO", self) fileFilterLayout = qt.QHBoxLayout() fileFilterLayout.addWidget(labelFilter) fileFilterLayout.addWidget(self.editFileFilter, 1) layout = qt.QVBoxLayout() layout.setContentsMargins(2, 0, 0, 0) layout.addLayout(fileFilterLayout) layout.addWidget(self.files) layout.addWidget(self.filesAutoAddCB) splitterInner.setLayout(layout) self.columnFormat = ColumnFormatWidget(self.splitterFiles, self.node) self.splitterFiles.setStretchFactor(0, 1) # don't remove self.splitterFiles.setStretchFactor(1, 0)
def __init__(self, parent=None, node=None): super(CombineSpectraWidget, self).__init__(parent, node) combineDataGroup = self.makeCombineDataGroup() layout = qt.QVBoxLayout() layout.setContentsMargins(4, 2, 2, 0) self.stopHereCB = qt.QCheckBox("stop data propagation here (TODO)") layout.addWidget(self.stopHereCB) layout.addWidget(combineDataGroup) layout.addStretch() self.setLayout(layout) self.combineTypeChanged(0) self.combineStopCBChanged(0)
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): qt.QWidget.__init__(self, parent) self.setWindowTitle("FitConfigGUI") layout = qt.QGridLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(6) self.FunLabel = qt.QLabel(self) self.FunLabel.setText("Function") layout.addWidget(self.FunLabel, 0, 0) self.FunComBox = qt.QComboBox(self) self.FunComBox.addItem("Add Function(s)") self.FunComBox.setItemData(self.FunComBox.findText("Add Function(s)"), "Load fit theories from a file", qt.Qt.ToolTipRole) layout.addWidget(self.FunComBox, 0, 1) self.BkgLabel = qt.QLabel(self) self.BkgLabel.setText("Background") layout.addWidget(self.BkgLabel, 1, 0) self.BkgComBox = qt.QComboBox(self) self.BkgComBox.addItem("Add Background(s)") self.BkgComBox.setItemData( self.BkgComBox.findText("Add Background(s)"), "Load background theories from a file", qt.Qt.ToolTipRole) layout.addWidget(self.BkgComBox, 1, 1) self.FunConfigureButton = qt.QPushButton(self) self.FunConfigureButton.setText("Configure") self.FunConfigureButton.setToolTip( "Open a configuration dialog for the selected function") layout.addWidget(self.FunConfigureButton, 0, 2) self.BgConfigureButton = qt.QPushButton(self) self.BgConfigureButton.setText("Configure") self.BgConfigureButton.setToolTip( "Open a configuration dialog for the selected background") layout.addWidget(self.BgConfigureButton, 1, 2) self.WeightCheckBox = qt.QCheckBox(self) self.WeightCheckBox.setText("Weighted fit") self.WeightCheckBox.setToolTip( "Enable usage of weights in the least-square problem.\n Use" + " the uncertainties (sigma) if provided, else use sqrt(y).") layout.addWidget(self.WeightCheckBox, 0, 3, 2, 1) layout.setColumnStretch(4, 1)
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 __init__(self, text, parent, value, checked=False): qt.QWidget.__init__(self, parent=parent) self.setLayout(qt.QHBoxLayout()) self._qcb = qt.QCheckBox(parent=self, text=text) self.layout().addWidget(self._qcb) self._qLineEdit = qt.QLineEdit() self.layout().addWidget(self._qLineEdit) self._qcb.toggled.connect(self.updateVis) self.set(value=value, checked=checked) self._qLineEdit.textChanged.connect(self._valueChanged)
def __init__(self, parent=None): qt.QDialog.__init__(self, parent) self.setWindowTitle("Median filter options") self.mainLayout = qt.QHBoxLayout(self) self.setLayout(self.mainLayout) # filter width GUI self.mainLayout.addWidget(qt.QLabel('filter width:', parent=self)) self._filterWidth = qt.QSpinBox(parent=self) self._filterWidth.setMinimum(1) self._filterWidth.setValue(1) self._filterWidth.setSingleStep(2) widthTooltip = """radius width of the pixel including in the filter for each pixel""" self._filterWidth.setToolTip(widthTooltip) self._filterWidth.valueChanged.connect(self._filterOptionChanged) self.mainLayout.addWidget(self._filterWidth) # filter option GUI self._filterOption = qt.QCheckBox('conditional', parent=self) conditionalTooltip = """if check, implement a conditional filter""" self._filterOption.stateChanged.connect(self._filterOptionChanged) self.mainLayout.addWidget(self._filterOption)
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 __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 populateOptions(self): grid = self.ui.optionsGrid # remove all old options for i in reversed(range(grid.count())): grid.itemAt(i).widget().setParent(None) # add new ones opts = self._current_subclass_opts() self.formWidgets = {} i = 0 for name, opt in opts.items(): # special: the options scanNr and fileName (or path) have their input # widgets at the top of the GUI for convenience, while dataSource is # handled per tab. if name in ('dataSource', 'scanNr', 'path', 'fileName'): continue grid.addWidget(qt.QLabel(name), i, 0) grid.addWidget(qt.QLabel(opt['doc']), i, 2) if opt['type'] == int: w = qt.QSpinBox() w.setMaximum(9999) w.setValue(opt['value']) elif opt['type'] == float: w = qt.QDoubleSpinBox() w.setValue(opt['value']) elif opt['type'] == bool: w = qt.QCheckBox() w.setChecked(opt['value']) elif opt['type'] in (list, tuple): w = qt.QLineEdit() w.setText(str(opt['value'])) w.evaluate_me = True elif type(opt['type']) in (list, tuple): w = qt.QComboBox() defaultindex = 0 for j, item in enumerate(opt['type']): w.addItem(item) if item == opt['value']: defaultindex = j w.setCurrentIndex(defaultindex) else: w = qt.QLineEdit() w.setText(opt['value']) w.evaluate_me = False grid.addWidget(w, i, 1) # save a dict of the options widgets, to parse when loading self.formWidgets[name] = w i += 1 # add a vertical spacer on the last line to make the table more compact grid.setRowStretch(i, 1) # special treatment oldtext = str(self.ui.filenameBox.text()) if 'path' in opts.keys() and oldtext.startswith('<'): self.ui.filenameBox.setText('<data path>') elif 'fileName' in opts.keys() and oldtext.startswith('<'): self.ui.filenameBox.setText('<input file>') self.ui.filenameBox.setDisabled(not ( 'path' in opts.keys() or 'fileName' in opts.keys())) self.ui.browseButton.setDisabled(not ( 'path' in opts.keys() or 'fileName' in opts.keys())) self.ui.scanNumberBox.setDisabled('scanNr' not in opts.keys()) # per-tab dataSource option boxes = { self.ui.dataSource2dBox: 2, self.ui.dataSource1dBox: 1, self.ui.dataSource0dBox: 0 } subclass_ = str(self.ui.scanClassBox.currentText()) try: subclass = getattr(nmutils.core, subclass_) except AttributeError: subclass = None for box, dim in boxes.items(): box.clear() if subclass is not None: for name in opts['dataSource']['type']: if hasattr(subclass, 'sourceDims' ) and not subclass.sourceDims[name] == dim: continue box.addItem(name) box.addItem('')
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): super(PrintGeometryWidget, self).__init__(parent) self.mainLayout = qt.QGridLayout(self) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.setSpacing(2) hbox = qt.QWidget() hboxLayout = qt.QHBoxLayout(hbox) hboxLayout.setContentsMargins(0, 0, 0, 0) hboxLayout.setSpacing(2) label = qt.QLabel(self) label.setText("Units") label.setAlignment(qt.Qt.AlignCenter) self._pageButton = qt.QRadioButton() self._pageButton.setText("Page") self._inchButton = qt.QRadioButton() self._inchButton.setText("Inches") self._cmButton = qt.QRadioButton() self._cmButton.setText("Centimeters") self._buttonGroup = qt.QButtonGroup(self) self._buttonGroup.addButton(self._pageButton) self._buttonGroup.addButton(self._inchButton) self._buttonGroup.addButton(self._cmButton) self._buttonGroup.setExclusive(True) # units self.mainLayout.addWidget(label, 0, 0, 1, 4) hboxLayout.addWidget(self._pageButton) hboxLayout.addWidget(self._inchButton) hboxLayout.addWidget(self._cmButton) self.mainLayout.addWidget(hbox, 1, 0, 1, 4) self._pageButton.setChecked(True) # xOffset label = qt.QLabel(self) label.setText("X Offset:") self.mainLayout.addWidget(label, 2, 0) self._xOffset = qt.QLineEdit(self) validator = qt.QDoubleValidator(None) self._xOffset.setValidator(validator) self._xOffset.setText("0.1") self.mainLayout.addWidget(self._xOffset, 2, 1) # yOffset label = qt.QLabel(self) label.setText("Y Offset:") self.mainLayout.addWidget(label, 2, 2) self._yOffset = qt.QLineEdit(self) validator = qt.QDoubleValidator(None) self._yOffset.setValidator(validator) self._yOffset.setText("0.1") self.mainLayout.addWidget(self._yOffset, 2, 3) # width label = qt.QLabel(self) label.setText("Width:") self.mainLayout.addWidget(label, 3, 0) self._width = qt.QLineEdit(self) validator = qt.QDoubleValidator(None) self._width.setValidator(validator) self._width.setText("0.9") self.mainLayout.addWidget(self._width, 3, 1) # height label = qt.QLabel(self) label.setText("Height:") self.mainLayout.addWidget(label, 3, 2) self._height = qt.QLineEdit(self) validator = qt.QDoubleValidator(None) self._height.setValidator(validator) self._height.setText("0.9") self.mainLayout.addWidget(self._height, 3, 3) # aspect ratio self._aspect = qt.QCheckBox(self) self._aspect.setText("Keep screen aspect ratio") self._aspect.setChecked(True) self.mainLayout.addWidget(self._aspect, 4, 1, 1, 2)
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 __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, parent=None): qt.QWidget.__init__(self, parent) self.mainLayout = qt.QGridLayout(self) self.mainLayout.setColumnStretch(1, 1) # Algorithm choice --------------------------------------------------- self.algorithmComboLabel = qt.QLabel(self) self.algorithmComboLabel.setText("Background algorithm") self.algorithmCombo = qt.QComboBox(self) self.algorithmCombo.addItem("Strip") self.algorithmCombo.addItem("Snip") self.algorithmCombo.activated[int].connect( self._algorithmComboActivated) # Strip parameters --------------------------------------------------- self.stripWidthLabel = qt.QLabel(self) self.stripWidthLabel.setText("Strip Width") self.stripWidthSpin = qt.QSpinBox(self) self.stripWidthSpin.setMaximum(100) self.stripWidthSpin.setMinimum(1) self.stripWidthSpin.valueChanged[int].connect(self._emitSignal) self.stripIterLabel = qt.QLabel(self) self.stripIterLabel.setText("Strip Iterations") self.stripIterValue = qt.QLineEdit(self) validator = qt.QIntValidator(self.stripIterValue) self.stripIterValue._v = validator self.stripIterValue.setText("0") self.stripIterValue.editingFinished[()].connect(self._emitSignal) self.stripIterValue.setToolTip( "Number of iterations for strip algorithm.\n" + "If greater than 999, an 2nd pass of strip filter is " + "applied to remove artifacts created by first pass.") # Snip parameters ---------------------------------------------------- self.snipWidthLabel = qt.QLabel(self) self.snipWidthLabel.setText("Snip Width") self.snipWidthSpin = qt.QSpinBox(self) self.snipWidthSpin.setMaximum(300) self.snipWidthSpin.setMinimum(0) self.snipWidthSpin.valueChanged[int].connect(self._emitSignal) # Smoothing parameters ----------------------------------------------- self.smoothingFlagCheck = qt.QCheckBox(self) self.smoothingFlagCheck.setText("Smoothing Width (Savitsky-Golay)") self.smoothingFlagCheck.toggled.connect(self._smoothingToggled) self.smoothingSpin = qt.QSpinBox(self) self.smoothingSpin.setMinimum(3) #self.smoothingSpin.setMaximum(40) self.smoothingSpin.setSingleStep(2) self.smoothingSpin.valueChanged[int].connect(self._emitSignal) # Anchors ------------------------------------------------------------ self.anchorsGroup = qt.QWidget(self) anchorsLayout = qt.QHBoxLayout(self.anchorsGroup) anchorsLayout.setSpacing(2) anchorsLayout.setContentsMargins(0, 0, 0, 0) self.anchorsFlagCheck = qt.QCheckBox(self.anchorsGroup) self.anchorsFlagCheck.setText("Use anchors") self.anchorsFlagCheck.setToolTip( "Define X coordinates of points that must remain fixed") self.anchorsFlagCheck.stateChanged[int].connect( self._anchorsToggled) anchorsLayout.addWidget(self.anchorsFlagCheck) maxnchannel = 16384 * 4 # Fixme ? self.anchorsList = [] num_anchors = 4 for i in range(num_anchors): anchorSpin = qt.QSpinBox(self.anchorsGroup) anchorSpin.setMinimum(0) anchorSpin.setMaximum(maxnchannel) anchorSpin.valueChanged[int].connect(self._emitSignal) anchorsLayout.addWidget(anchorSpin) self.anchorsList.append(anchorSpin) # Layout ------------------------------------------------------------ self.mainLayout.addWidget(self.algorithmComboLabel, 0, 0) self.mainLayout.addWidget(self.algorithmCombo, 0, 2) self.mainLayout.addWidget(self.stripWidthLabel, 1, 0) self.mainLayout.addWidget(self.stripWidthSpin, 1, 2) self.mainLayout.addWidget(self.stripIterLabel, 2, 0) self.mainLayout.addWidget(self.stripIterValue, 2, 2) self.mainLayout.addWidget(self.snipWidthLabel, 3, 0) self.mainLayout.addWidget(self.snipWidthSpin, 3, 2) self.mainLayout.addWidget(self.smoothingFlagCheck, 4, 0) self.mainLayout.addWidget(self.smoothingSpin, 4, 2) self.mainLayout.addWidget(self.anchorsGroup, 5, 0, 1, 4) # Initialize interface ----------------------------------------------- self._setAlgorithm("strip") self.smoothingFlagCheck.setChecked(False) self._smoothingToggled(is_checked=False) self.anchorsFlagCheck.setChecked(False) self._anchorsToggled(is_checked=False)