def __init__(self, parent, controller): super(EditorScale, self).__init__(parent, controller) self.controller = controller self.scaleX = QtWidgets.QHBoxLayout(self) self.scaleXLabel = QtWidgets.QLabel("Scale X: ") self.scaleXLineEdit = QtWidgets.QLineEdit() self.scaleXLineEdit.setValidator(QtGui.QDoubleValidator(-1000,1000, 5,self)) self.scaleXLineEdit.textEdited.connect(self.setValues) self.scaleX.addWidget(self.scaleXLabel) self.scaleX.addWidget(self.scaleXLineEdit) self.layout.addLayout(self.scaleX) self.scaleY = QtWidgets.QHBoxLayout(self) self.scaleYLabel = QtWidgets.QLabel("Scale Y: ") self.scaleYLineEdit = QtWidgets.QLineEdit() self.scaleYLineEdit.setValidator(QtGui.QDoubleValidator(-1000,1000, 5,self)) self.scaleYLineEdit.textEdited.connect(self.setValues) self.scaleY.addWidget(self.scaleYLabel) self.scaleY.addWidget(self.scaleYLineEdit) self.layout.addLayout(self.scaleY) self.scaleZ = QtWidgets.QHBoxLayout(self) self.scaleZLabel = QtWidgets.QLabel("Scale Z: ") self.scaleZLineEdit = QtWidgets.QLineEdit() self.scaleZLineEdit.setValidator(QtGui.QDoubleValidator(-1000,1000, 5,self)) self.scaleZLineEdit.textEdited.connect(self.setValues) self.scaleZ.addWidget(self.scaleZLabel) self.scaleZ.addWidget(self.scaleZLineEdit) self.layout.addLayout(self.scaleZ) self.setLayout(self.layout)
def __init__(self, parent, controller): super(EditorInitial, self).__init__(parent, controller) self.controller = controller self.lotX = QtWidgets.QHBoxLayout(self) self.lotXLabel = QtWidgets.QLabel("Lot X: ") self.lotXLineEdit = QtWidgets.QLineEdit() self.lotXLineEdit.setValidator(QtGui.QDoubleValidator(-1000,1000, 5,self)) self.lotXLineEdit.textEdited.connect(self.setValues) self.lotX.addWidget(self.lotXLabel) self.lotX.addWidget(self.lotXLineEdit) self.layout.addLayout(self.lotX) self.lotY = QtWidgets.QHBoxLayout(self) self.lotYLabel = QtWidgets.QLabel("Lot Y: ") self.lotYLineEdit = QtWidgets.QLineEdit() self.lotYLineEdit.setValidator(QtGui.QDoubleValidator(-1000,1000, 5,self)) self.lotYLineEdit.textEdited.connect(self.setValues) self.lotY.addWidget(self.lotYLabel) self.lotY.addWidget(self.lotYLineEdit) self.layout.addLayout(self.lotY) self.lotZ = QtWidgets.QHBoxLayout(self) self.lotZLabel = QtWidgets.QLabel("Lot Z: ") self.lotZLineEdit = QtWidgets.QLineEdit() self.lotZLineEdit.setValidator(QtGui.QDoubleValidator(-1000,1000, 5,self)) self.lotZLineEdit.textEdited.connect(self.setValues) self.lotZ.addWidget(self.lotZLabel) self.lotZ.addWidget(self.lotZLineEdit) self.layout.addLayout(self.lotZ) self.setLayout(self.layout)
def __setValueInternal(self, value, reason): # update our validator based on the type of the value numericType = type(value) assert (numericType is int or numericType is float) if self.__numericType is not numericType: self.__numericType = numericType if self.__numericType is int: validator = QtGui.QIntValidator(self._qtWidget()) else: validator = QtGui.QDoubleValidator(self._qtWidget()) validator.setDecimals(4) validator.setNotation(QtGui.QDoubleValidator.StandardNotation) self._qtWidget().setValidator(validator) # update our textual value text = self.__valueToString(value) dragBeginOrEnd = reason in (self.ValueChangedReason.DragBegin, self.ValueChangedReason.DragEnd) if text == self.getText() and not dragBeginOrEnd: # early out if the text hasn't changed. we never early out if the reason is # drag start or drag end, as we want to maintain matching pairs so things # make sense to client code. return self.setText(text) self.__emitValueChanged(reason)
def set_data_type(self, dt): if dt is int: self.setValidator(QtGui.QIntValidator()) elif dt is float: self.setValidator(QtGui.QDoubleValidator()) self._data_type = dt self.menu.set_data_type(dt)
def createEditor(self, parent, option, index): editor = QtGui.QLineEdit(parent) if self.ogtHeading.type.endswith("DP"): validator = QtGui.QDoubleValidator() validator.setDecimals(self.dp) editor.setValidator(validator) return editor
def __init__(self,parent): QtGui.QDialog.__init__(self,parent,QtCore.Qt.WindowTitleHint) self.setupUi(self) settings = QtCore.QSettings() if(settings.value("scrollDirection") == -1): self.natural.setChecked(True) self.traditional.setChecked(False) else: self.natural.setChecked(False) self.traditional.setChecked(True) self.imageCacheSpin.setValue(int(settings.value("imageCacheSize"))) self.maskCacheSpin.setValue(int(settings.value("maskCacheSize"))) self.geometryCacheSpin.setValue(int(settings.value("geometryCacheSize"))) self.textureCacheSpin.setValue(int(settings.value("textureCacheSize"))) self.updateTimerSpin.setValue(int(settings.value("updateTimer"))) self.movingAverageSizeSpin.setValue(float(settings.value("movingAverageSize"))) self.PNGOutputPath.setText(settings.value("PNGOutputPath")) self.shortcutsTable.installEventFilter(self) shortcuts = settings.value("Shortcuts") for r in range(0,self.shortcutsTable.rowCount()): name = self.shortcutsTable.verticalHeaderItem(r).text() if(name in shortcuts.keys()): string = QtGui.QKeySequence.fromString(shortcuts[name]).toString(QtGui.QKeySequence.NativeText) self.shortcutsTable.item(r,0).setText(string) self.modelCenterX.setText(str(settings.value("modelCenterX"))) self.modelCenterY.setText(str(settings.value("modelCenterY"))) self.modelDiameter.setText(str(settings.value("modelDiameter"))) self.modelIntensity.setText(str(settings.value("modelIntensity"))) self.modelMaskRadius.setText(str(settings.value("modelMaskRadius"))) # Set validators validator = QtGui.QDoubleValidator() self.modelCenterX.setValidator(validator) self.modelCenterY.setValidator(validator) validator = QtGui.QDoubleValidator() validator.setBottom(0) self.modelDiameter.setValidator(validator) self.modelIntensity.setValidator(validator) self.modelMaskRadius.setValidator(validator)
def __init__(self, parent): QtGui.QGroupBox.__init__(self, parent) self.setupUi(self) self.parent = parent self.intensityHistogram.setSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Preferred) self.intensityHistogram.hideAxis('left') self.intensityHistogram.hideAxis('bottom') self.intensityHistogram.setFixedHeight(50) region = pyqtgraph.LinearRegionItem(values=[0, 1], brush="#ffffff15") self.intensityHistogram.addItem(region) self.intensityHistogram.autoRange() self.intensityHistogramRegion = region self.imageData = None self.x = None self.hist = None self.vMin = None self.vMax = None self.displayMin.setValidator(QtGui.QDoubleValidator()) self.displayMax.setValidator(QtGui.QDoubleValidator()) self.displayColormap.setFixedSize(QtCore.QSize(160, 32)) self.displayColormap.setMenu(self.parent.viewer.colormapMenu)
def __init__(self, parent, controller): super(EditorSplitSegment, self).__init__(parent, controller) self.controller = controller self.proportion = QtWidgets.QHBoxLayout(self) self.proportionLabel = QtWidgets.QLabel("Proportion: ") self.proportionLineEdit = QtWidgets.QLineEdit() self.proportionLineEdit.setValidator(QtGui.QDoubleValidator(0,1000,5,self)) self.proportionLineEdit.textEdited.connect(self.setValues) self.proportion.addWidget(self.proportionLabel) self.proportion.addWidget(self.proportionLineEdit) self.layout.addLayout(self.proportion) self.setLayout(self.layout)
def __init__(self, nuke_knob=''): super(Knob_EditBox, self).__init__() # Instance ID self.nuke_knob = nuke_knob + '_editbox' self.Class = 'Knob_EditBox' # Instance properties self.setFixedSize(72, WIDGET_HEIGHT) self.setSingleStep(0.0001) self.setDecimals(4) self.setButtonSymbols(self.NoButtons) self.setRange(-10000000.0000, 10000000.0000) self.lineEdit().setValidator(QtGui.QDoubleValidator().setDecimals(4)) self.lineEdit().cursorPositionChanged.connect(self.onEdit)
def child_arg(self, layout, index): widget = QtWidgets.QLineEdit() widget.setValidator(QtGui.QDoubleValidator()) default = str(float(self["default"][index])) widget.setText(default) def focusOutEvent(event): if not widget.text(): widget.setText(default) # Ensure value exists for `_read` QtWidgets.QLineEdit.focusOutEvent(widget, event) widget.focusOutEvent = focusOutEvent widget.editingFinished.connect(self.changed.emit) widget.returnPressed.connect(widget.editingFinished.emit) layout.addWidget(widget) return widget
def create_floatField(self, ui_name=None, label=None, min=None, max=None, dv=1.0, precision=None, parent=None, co=None): float_field = QtWidgets.QLineEdit() float_field.setAlignment(QtCore.Qt.AlignRight) validator = QtGui.QDoubleValidator() float_field.setValidator(validator) top_widget = float_field if label: layout = self.create_QHBoxLayout() label = self.create_QLabel(text=label, parent=layout) if ui_name: layout.setObjectName(ui_name + '_layout') label.setObjectName(ui_name + '_label') layout.addWidget(float_field) top_widget = layout if min: validator.setBottom(min) if max: validator.setTop(max) if dv: float_field.setText(str(dv)) if precision: validator.setDecimals(precision) if ui_name: float_field.setObjectName(ui_name) validator.setObjectName(ui_name + '_validator') if parent: self.parent_QtWidgets(parent, top_widget, co=co) return (float_field)
def __init__(self): super(Second, self).__init__() self.setWindowTitle("Add new device") self.nameLabel = QLabel(self) self.nameLabel.move(10, 10) self.nameLabel.setText("Device name") self.nameEntry = QLineEdit(self) self.nameEntry.move(10, 40) self.nameEntry.resize(100, 30) self.colorLabel = QLabel(self) self.colorLabel.move(120, 10) self.colorLabel.setText("Color cameras") self.colorEntry = QLineEdit(self) self.colorEntry.move(140, 40) self.colorEntry.resize(70, 30) self.colorEntry.setValidator(QtGui.QIntValidator()) self.monoLabel = QLabel(self) self.monoLabel.move(230, 10) self.monoLabel.setText("Mono cameras") self.monoEntry = QLineEdit(self) self.monoEntry.move(250, 40) self.monoEntry.resize(70, 30) self.monoEntry.setValidator(QtGui.QIntValidator()) self.depthPresent = QCheckBox("Include depth", self) self.depthPresent.move(10, 80) self.depthPresent.resize(150, 30) self.depthPresent.stateChanged.connect(self.toggle_depth) self.leftfovLabel = QLabel(self) self.leftfovLabel.move(10, 120) self.leftfovLabel.setText("Left FOV deg.") self.leftfovEntry = QLineEdit(self) self.leftfovEntry.move(180, 120) self.leftfovEntry.resize(140, 30) self.leftfovEntry.setValidator(QtGui.QDoubleValidator()) self.rightfovLabel = QLabel(self) self.rightfovLabel.move(10, 160) self.rightfovLabel.setText("Right FOV deg.") self.rightfovEntry = QLineEdit(self) self.rightfovEntry.move(180, 160) self.rightfovEntry.resize(140, 30) self.rightfovEntry.setValidator(QtGui.QDoubleValidator()) self.rgbfovLabel = QLabel(self) self.rgbfovLabel.move(10, 200) self.rgbfovLabel.setText("RGB FOV deg.") self.rgbfovEntry = QLineEdit(self) self.rgbfovEntry.move(180, 200) self.rgbfovEntry.resize(140, 30) self.rgbfovEntry.setValidator(QtGui.QDoubleValidator()) self.lrdistanceLabel = QLabel(self) self.lrdistanceLabel.move(10, 240) self.lrdistanceLabel.resize(200, 30) self.lrdistanceLabel.setText("Left - Right distance cm.") self.lrdistanceEntry = QLineEdit(self) self.lrdistanceEntry.move(180, 240) self.lrdistanceEntry.resize(140, 30) self.lrdistanceEntry.setValidator(QtGui.QDoubleValidator()) self.lrgbdistanceLabel = QLabel(self) self.lrgbdistanceLabel.move(10, 280) self.lrgbdistanceLabel.resize(200, 30) self.lrgbdistanceLabel.setText("Left - RGB distance cm.") self.lrgbdistanceEntry = QLineEdit(self) self.lrgbdistanceEntry.move(180, 280) self.lrgbdistanceEntry.resize(140, 30) self.lrgbdistanceEntry.setValidator(QtGui.QDoubleValidator()) self.saveButton = QPushButton("Save", self) self.saveButton.resize(100, 30) self.saveButton.clicked.connect(self.save) self.cancelButton = QPushButton("Cancel", self) self.cancelButton.resize(100, 30) self.cancelButton.clicked.connect(self.cancel) self.toggle_depth(False)
CWD= os.path.dirname(os.path.realpath(__file__) ) def main_maya_window(): maya_window_ptr=omUI.MQtUtil.mainWindow() return wrapInstance(long(maya_window_ptr), QtWidgets.QWidget) class Form(QtWidgets.QDialog): def __init__(self,parent=None): super(Form, self).__init__(parent=main_maya_window() ) self.title = “node manager” self.setwindowtitle(self.title) self.__init_ui__() self.__init_signals__() def deleteUI(self, name): if cmds.window(name, exists=True) : cmds.deleteUI(name) def__init_ui__(self): loader = QUiloader() validator= QtGui.QDoubleValidator() self.ui = loader.load({}/node_manager.ui”.format(CWD), None) self.ui.reverseCheck.setVisible(False) self.ui.title = ‘Node Manager’ self.deleteUI(self.title) self.setObjectName(self.title) self.__callbacks__() self.ui.remapInMax.setValidator(validator)
def __init__(self, parent, dataItem): QtGui.QWidget.__init__(self, parent) vbox = QtGui.QVBoxLayout() nameLabel = QtGui.QLabel(dataItem.fullName) yieldLabel = QtGui.QLabel("") data = dataItem.data() vmin = numpy.min(data) vmax = numpy.max(data) self.histogram = pyqtgraph.PlotWidget(self) self.histogram.hideAxis('left') self.histogram.hideAxis('bottom') self.histogram.setFixedHeight(50) # Make the histogram fit the available width self.histogram.setSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Preferred) region = pyqtgraph.LinearRegionItem(values=[vmin, vmax], brush="#ffffff15") region.sigRegionChangeFinished.connect(self.syncLimits) self.histogram.addItem(region) self.histogram.autoRange() vbox.addWidget(self.histogram) vbox.addWidget(nameLabel) vbox.addWidget(yieldLabel) # for non-boolean filters hbox = QtGui.QHBoxLayout() self.vminLabel = QtGui.QLabel("Min.:") hbox.addWidget(self.vminLabel) self.vmaxLabel = QtGui.QLabel("Max.:") hbox.addWidget(self.vmaxLabel) vbox.addLayout(hbox) hbox = QtGui.QHBoxLayout() validator = QtGui.QDoubleValidator() validator.setDecimals(3) validator.setNotation(QtGui.QDoubleValidator.ScientificNotation) self.vminLineEdit = QtGui.QLineEdit(self) self.vminLineEdit.setText("%.7e" % (vmin * 0.999)) self.vminLineEdit.setValidator(validator) hbox.addWidget(self.vminLineEdit) self.vmaxLineEdit = QtGui.QLineEdit(self) self.vmaxLineEdit.setText("%.7e" % (vmax * 1.001)) self.vmaxLineEdit.setValidator(validator) hbox.addWidget(self.vmaxLineEdit) vbox.addLayout(hbox) # for boolean filters hbox = QtGui.QHBoxLayout() self.invertLabel = QtGui.QLabel("Invert") hbox.addWidget(self.invertLabel) self.invertCheckBox = QtGui.QCheckBox("", parent=self) hbox.addWidget(self.invertCheckBox) hbox.addStretch() vbox.addLayout(hbox) self.setNonBooleanFilter() # for 2-dimensional datasets hbox = QtGui.QHBoxLayout() self.indexLabel = QtGui.QLabel("Index:") hbox.addWidget(self.indexLabel) self.indexCombo = QtGui.QComboBox() hbox.addWidget(self.indexCombo) vbox.addLayout(hbox) self.set1DimensionalDataset() self.setLayout(vbox) self.histogram.region = region self.histogram.itemPlot = None self.nameLabel = nameLabel self.yieldLabel = yieldLabel self.vbox = vbox self.refreshData(dataItem) self.vminLineEdit.editingFinished.connect(self.emitLimitsChanged) self.vmaxLineEdit.editingFinished.connect(self.emitLimitsChanged) self.indexCombo.currentIndexChanged.connect( self.emitSelectedIndexChanged) self.invertCheckBox.toggled.connect(self.syncLimits)
def __init__(self, parent=None, indexProjector=None): QtGui.QWidget.__init__(self, parent) self.setFocusPolicy(QtCore.Qt.ClickFocus) self.viewer = parent self.indexProjector = indexProjector # this dict holds all current settings self.view2DProp = {} self.view1DProp = {} self.vbox = QtGui.QVBoxLayout() # stack self.stackSize = None self.settings = QtCore.QSettings() # scrolling self.vboxScroll = QtGui.QVBoxLayout() self.vboxScroll.setContentsMargins(0, 0, 11, 0) self.scrollWidget = QtGui.QWidget() self.scrollWidget.setLayout(self.vboxScroll) self.scrollArea = QtGui.QScrollArea() self.scrollArea.setWidgetResizable(True) self.scrollArea.setFrameShape(QtGui.QFrame.NoFrame) self.scrollArea.setWidget(self.scrollWidget) self.scrollArea.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.vbox.addWidget(self.scrollArea) # GENERAL PROPERTIES # properties: data self.generalBox = QtGui.QGroupBox("General Properties") self.generalBox.vbox = QtGui.QVBoxLayout() self.generalBox.setLayout(self.generalBox.vbox) self.shape = QtGui.QLabel("Shape:", parent=self) self.datatype = QtGui.QLabel("Data Type:", parent=self) self.datasize = QtGui.QLabel("Data Size:", parent=self) self.dataform = QtGui.QLabel("Data Form:", parent=self) self.generalBox.vbox.addWidget(self.shape) self.generalBox.vbox.addWidget(self.datatype) self.generalBox.vbox.addWidget(self.datasize) self.generalBox.vbox.addWidget(self.dataform) # properties: image stack self.imageStackBox = QtGui.QGroupBox("Image Stack") self.imageStackBox.vbox = QtGui.QVBoxLayout() self.imageStackBox.setLayout(self.imageStackBox.vbox) # property: image stack plots width hbox = QtGui.QHBoxLayout() hbox.addWidget(QtGui.QLabel("Width:")) self.imageStackSubplots = QtGui.QSpinBox(parent=self) self.imageStackSubplots.setMinimum(1) # self.imageStackSubplots.setMaximum(5) hbox.addWidget(self.imageStackSubplots) self.imageStackBox.vbox.addLayout(hbox) # DISPLAY PROPERTIES self.displayBox = DisplayBox(self) # sorting self.sortingBox = QtGui.QGroupBox("Sorting") self.sortingBox.vbox = QtGui.QVBoxLayout() self.sortingDataLabel = QtGui.QLabel("", parent=self) self.sortingBox.vbox.addWidget(self.sortingDataLabel) hbox = QtGui.QHBoxLayout() hbox.addWidget(QtGui.QLabel("Invert")) self.invertSortingCheckBox = QtGui.QCheckBox("", parent=self) hbox.addWidget(self.invertSortingCheckBox) hbox.addStretch() self.sortingBox.vbox.addLayout(hbox) self.sortingBox.setLayout(self.sortingBox.vbox) self.clearSorting() # filters self.filterBox = QtGui.QGroupBox("Filters") self.filterBox.vbox = QtGui.QVBoxLayout() self.filterBox.setLayout(self.filterBox.vbox) self.filterBox.hide() self.activeFilters = [] self.inactiveFilters = [] # plot box self.plotBox = QtGui.QGroupBox("Plot") self.plotBox.vbox = QtGui.QVBoxLayout() validatorInt = QtGui.QIntValidator() validatorInt.setBottom(0) validatorSci = QtGui.QDoubleValidator() validatorSci.setDecimals(3) validatorSci.setNotation(QtGui.QDoubleValidator.ScientificNotation) self.plotNBinsEdit = QtGui.QLineEdit(self) self.plotNBinsEdit.setMaximumWidth(100) self.plotNBinsEdit.setValidator(validatorInt) hbox = QtGui.QHBoxLayout() hbox.addWidget(QtGui.QLabel("# bins:")) hbox.addWidget(self.plotNBinsEdit) self.plotBox.vbox.addLayout(hbox) hbox = QtGui.QHBoxLayout() hbox.addWidget(QtGui.QLabel("Lines:")) self.plotLinesCheckBox = QtGui.QCheckBox("", parent=self) self.plotLinesCheckBox.setChecked(True) hbox.addWidget(self.plotLinesCheckBox) self.plotBox.vbox.addLayout(hbox) hbox = QtGui.QHBoxLayout() hbox.addWidget(QtGui.QLabel("Points:")) self.plotPointsCheckBox = QtGui.QCheckBox("", parent=self) hbox.addWidget(self.plotPointsCheckBox) self.plotBox.vbox.addLayout(hbox) self.plotBoxValueLabel = None self.plotBox.setLayout(self.plotBox.vbox) self.plotBox.hide() self.modelProperties = ModelProperties(self) self.modelProperties.hide() self.pattersonProperties = PattersonProperties(self) self.pattersonProperties.hide() # add all widgets to main vbox self.vboxScroll.addWidget(self.generalBox) self.vboxScroll.addWidget(self.displayBox) self.vboxScroll.addWidget(self.imageStackBox) self.vboxScroll.addWidget(self.sortingBox) self.vboxScroll.addWidget(self.filterBox) self.vboxScroll.addWidget(self.plotBox) self.vboxScroll.addWidget(self.modelProperties) self.vboxScroll.addWidget(self.pattersonProperties) self.vboxScroll.addStretch() self.setLayout(self.vbox) # clear all properties self.clear() # connect signals self.imageStackSubplots.editingFinished.connect(self.emitView2DProp) self.displayBox.displayMax.editingFinished.connect(self.checkLimits) self.displayBox.displayMin.editingFinished.connect(self.checkLimits) self.displayBox.displayMaxUnit.currentIndexChanged.connect( self.checkLimits) self.displayBox.displayMinUnit.currentIndexChanged.connect( self.checkLimits) self.displayBox.displayClamp.stateChanged.connect(self.emitView2DProp) self.displayBox.displayInvert.stateChanged.connect(self.emitView2DProp) #self.displayBox.displayAutorange.stateChanged.connect(self.emitView2DProp) self.displayBox.displayScale.currentIndexChanged.connect( self.emitView2DProp) self.invertSortingCheckBox.toggled.connect(self.emitView2DProp) self.invertSortingCheckBox.toggled.connect(self.emitView1DProp) self.viewer.colormapActionGroup.triggered.connect(self.emitView2DProp) self.plotLinesCheckBox.toggled.connect(self.emitView1DProp) self.plotPointsCheckBox.toggled.connect(self.emitView1DProp) self.plotNBinsEdit.editingFinished.connect(self.emitView1DProp)