def createDataGroupBox(self): # build the container for input data self.dataGroupBox = QtWidgets.QGroupBox("curve input data", self) grid = QtWidgets.QGridLayout() self.label_function = QtWidgets.QLabel("function", self) grid.addWidget(self.label_function, 0, 0) self.lineEdit_function = QtWidgets.QLineEdit(self) self.lineEdit_function.setPlaceholderText("function") grid.addWidget(self.lineEdit_function, 0, 1, 1, -1) # make it wider self.label_xMin = QtWidgets.QLabel("X min", self) grid.addWidget(self.label_xMin, 1, 0) self.lineEdit_xMin = QtWidgets.QLineEdit(self) self.lineEdit_xMin.setPlaceholderText("X min") self.lineEdit_xMin.setValidator(QtGui.QDoubleValidator()) grid.addWidget(self.lineEdit_xMin, 1, 1) self.label_xMax = QtWidgets.QLabel("X max", self) grid.addWidget(self.label_xMax, 1, 2) self.lineEdit_xMax = QtWidgets.QLineEdit(self) self.lineEdit_xMax.setPlaceholderText("X max") self.lineEdit_xMax.setValidator(QtGui.QDoubleValidator()) grid.addWidget(self.lineEdit_xMax, 1, 3) self.pushButton_plot = QtWidgets.QPushButton("plot", self) grid.addWidget(self.pushButton_plot, 1, 4) self.dataGroupBox.setLayout(grid)
def main(): coloredlogs.install(level="DEBUG") # bind UDP socket with socket.socket( socket.AF_INET, socket.SOCK_STREAM ) as sock: # internt IP with UDP sock.connect((TCP_IP, TCP_PORT)) logging.info(f"Connected to IP {TCP_IP} with port {TCP_PORT}") app = QtWidgets.QApplication(sys.argv) try: with open(STYLESHEET_NAME, "r") as stylesheet: app.setStyleSheet(stylesheet.read()) except FileNotFoundError: logging.warning(f"Could not find stylesheet {STYLESHEET_NAME}") window = QtWidgets.QWidget() window_layout = QtWidgets.QVBoxLayout() window.setLayout(window_layout) radar_label = QtWidgets.QLabel("Radar Data") radar_label.setAlignment(Qt.AlignCenter) window_layout.addWidget(radar_label) radar_image = RadarImage() radar_image.setAlignment(Qt.AlignCenter) window_layout.addWidget(radar_image) properties = QtWidgets.QWidget() properties_layout = QtWidgets.QGridLayout() properties.setLayout(properties_layout) window_layout.addWidget(properties) data_thread = DataThread(sock, radar_image) data_thread.new_data.connect(radar_image.update) data_thread.start() vmax_lineedit = QtWidgets.QLineEdit() vmax_lineedit.text = str(DEFAULT_VMAX) vmax_lineedit.setValidator(QtGui.QDoubleValidator()) vmax_lineedit.textChanged.connect(data_thread.new_vmax) properties_layout.addWidget(QtWidgets.QLabel("Colorramp VMax: "), 0, 0, 1, 1) properties_layout.addWidget(vmax_lineedit, 0, 1, 1, 1) log_constant_lineedit = QtWidgets.QLineEdit() log_constant_lineedit.text = str(DEFAULT_LOG_CONSTANT) log_constant_lineedit.setValidator(QtGui.QDoubleValidator()) log_constant_lineedit.textChanged.connect(data_thread.new_log_constant) properties_layout.addWidget(QtWidgets.QLabel("Log Constant: "), 1, 0, 1, 1) properties_layout.addWidget(log_constant_lineedit, 1, 1, 1, 1) window.show() qt_exit_code = app.exec_() logging.debug("Stopping thread...") data_thread.stopping = True logging.debug("Shutting down socket") data_thread.wait() sys.exit(qt_exit_code)
def __init__(self): """Initializer.""" super().__init__() self.setWindowTitle("Unit Converter") self.units = sorted(get_all_units(ureg)) # Widgets: self.input_value = QtWidgets.QLineEdit("1.0") self.input_value.setValidator(QtGui.QDoubleValidator()) self.input_value.setMinimumWidth(200) self.input_unit = QtWidgets.QComboBox() self.input_unit.addItems(self.units) self.input_unit.setEditable(True) self.input_unit.setInsertPolicy(QtWidgets.QComboBox.NoInsert) self.input_unit.setEditText("feet") self.output_value = QtWidgets.QLineEdit() self.output_value.setValidator(QtGui.QDoubleValidator()) self.output_value.setMinimumWidth(200) self.output_unit = QtWidgets.QComboBox() self.output_unit.addItems(self.units) self.output_unit.setEditable(True) self.input_unit.setInsertPolicy(QtWidgets.QComboBox.NoInsert) self.output_unit.setEditText("meter") self.convert_button = QtWidgets.QPushButton("Convert") self.convert_button.setDefault(True) self.convert_button.setFocusPolicy(QtCore.Qt.StrongFocus) self.switch_button = QtWidgets.QPushButton("Switch") self.switch_button.setFocusPolicy(QtCore.Qt.StrongFocus) self.clear_button = QtWidgets.QPushButton("Clear") # Layouts: self.input_layout = QtWidgets.QHBoxLayout() self.input_layout.addWidget(self.input_value) self.input_layout.addWidget(self.input_unit) self.output_layout = QtWidgets.QHBoxLayout() self.output_layout.addWidget(self.output_value) self.output_layout.addWidget(self.output_unit) self.control_layout = QtWidgets.QHBoxLayout() self.control_layout.addWidget(self.convert_button) self.control_layout.addWidget(self.switch_button) self.control_layout.addWidget(self.clear_button) # Main Layout: self.layout = QtWidgets.QVBoxLayout() self.layout.addLayout(self.input_layout) self.layout.addLayout(self.output_layout) self.layout.addLayout(self.control_layout) self.setLayout(self.layout) # Signals and Slots: self.convert_button.clicked.connect(self.convert) self.switch_button.clicked.connect(self.switch) self.clear_button.clicked.connect(self.clear)
def __init__(self,node, parent=None): super(redShiftTools_objSet_objectId_ui, self).__init__(parent) self.setupUi(self) self.node=node self.onlyFloat32 = QtGui.QDoubleValidator(0.0,32.0,2) self.onlyFloat1 = QtGui.QDoubleValidator(0.0,1.0,2) self.onlyInt = QtGui.QIntValidator(0,100) self.objectId_LE.setValidator(self.onlyInt) self.connectInterface() self.setAttr()
def initUI(self): vLayout = QtWidgets.QVBoxLayout(self) vLayout.setSpacing(0) vLayout.setContentsMargins(0, 0, 0, 0) upperLayout = QtWidgets.QHBoxLayout(self) upperLayout.setSpacing(0) self.objLabel = QtWidgets.QLabel('Nothing selected') self.objLabel.setIndent(11) upperLayout.addWidget(self.objLabel) reloadBtn = QtWidgets.QPushButton('Reload') reloadBtn.clicked.connect(self.updateValues) upperLayout.addWidget(reloadBtn) vLayout.addLayout(upperLayout) self.attrList = QtWidgets.QListWidget() vLayout.addWidget(self.attrList) self.chLabels = [None] * CHANNELS_NUM self.minLine = [None] * CHANNELS_NUM self.maxLine = [None] * CHANNELS_NUM for c in range(CHANNELS_NUM): # This will display 'ERROR' only if Window.updateValues() fails self.chLabels[c] = QtWidgets.QLabel('ERROR') self.chLabels[c].setContentsMargins(11, 0, 11, 0) self.minLine[c] = QtWidgets.QLineEdit() self.minLine[c].setValidator(QtGui.QDoubleValidator()) self.minLine[c].setPlaceholderText('Min') self.minLine[c].setFixedWidth(50) self.maxLine[c] = QtWidgets.QLineEdit() self.maxLine[c].setValidator(QtGui.QDoubleValidator()) self.maxLine[c].setPlaceholderText('Max') self.maxLine[c].setFixedWidth(50) connectBtn = QtWidgets.QPushButton( 'Connect channel #{0}'.format(c)) connectBtn.clicked.connect(self.channelBtnClicked(c)) connectBtn.setFixedWidth(120) row = QtWidgets.QHBoxLayout(self) row.addWidget(self.chLabels[c]) row.addWidget(self.minLine[c]) row.addWidget(self.maxLine[c]) row.addWidget(connectBtn) vLayout.addLayout(row) self.setLayout(vLayout)
def __init__(self,node, parent=None): super(redShiftTools_objSet_visbility_ui, self).__init__(parent) self.setupUi(self) self.node=node self.onlyFloat32 = QtGui.QDoubleValidator(0.0,32.0,2) self.onlyFloat1 = QtGui.QDoubleValidator(0.0,1.0,2) self.onlyInt = QtGui.QIntValidator(0,100) self.CB_list=[ self.primaryRayVis_CB, self.seconderayRayVis_CB, self.castShadow_CB, self.receivesShadow_CB, self.selfShadow_CB, self.castAo_CB, self.visInRefl_CB, self.visInRefr_CB, self.castsRefl_CB, self.castsRefr_CB, self.visToNonPhotonGi_CB, self.visToGiPhotons_CB, self.visCausticPhotons_CB, self.receivesGi_CB, self.forceBruteForceGi_CB, self.castsGiPhotons_CB, self.castsCausticPhotons_CB, self.receivesGiPhotons_CB, self.receivesCausticPhotons_CB ] self.attr_list=[ self.node.primaryRayVisible, self.node.secondaryRayVisible, self.node.shadowCaster, self.node.shadowReceiver, self.node.selfShadows, self.node.aoCaster, self.node.reflectionVisible, self.node.refractionVisible, self.node.reflectionCaster, self.node.refractionCaster, self.node.fgVisible, self.node.giVisible, self.node.causticVisible, self.node.fgCaster, self.node.forceBruteForceGI, self.node.giCaster, self.node.causticCaster, self.node.giReceiver, self.node.causticReceiver ] self.connectInterface() self.setAttr()
def __init__(self,node, parent=None): super(redShiftTools_objSet_matte_ui, self).__init__(parent) self.setupUi(self) self.node=node self.onlyFloat32 = QtGui.QDoubleValidator(0.0,32.0,2) self.onlyFloat1 = QtGui.QDoubleValidator(0.0,1,2) self.onlyInt = QtGui.QIntValidator(0,16) self.matteAlpha_LE.setValidator(self.onlyFloat32) self.matteReflectionScale_LE.setValidator(self.onlyInt) self.matteRefractionScale_LE.setValidator(self.onlyFloat32) self.matteDiffuseScale_LE.setValidator(self.onlyFloat32) self.shadowTransparency_LE.setValidator(self.onlyFloat32) self.connectInterface() self.setAttr()
def __init__(self,node, parent=None): super(redShiftTools_objSet_mesh_ui, self).__init__(parent) self.setupUi(self) self.node=node self.onlyFloat32 = QtGui.QDoubleValidator(0.0,32.0,2) self.onlyFloat1000 = QtGui.QDoubleValidator(0.0,1000,2) self.onlyInt = QtGui.QIntValidator(0,16) self.miniEdge_LE.setValidator(self.onlyFloat32) self.maxSd_LE.setValidator(self.onlyInt) self.factor_LE.setValidator(self.onlyFloat32) self.max_dm_LE.setValidator(self.onlyFloat32) self.dm_scale_LE.setValidator(self.onlyFloat32) self.setAttr() self.connectInterface()
def __init__(self, parent): super().__init__(parent) self.setTitle("Fill out required values for the parameter") layout = QtWidgets.QVBoxLayout() self.setLayout(layout) box = QtWidgets.QGroupBox("Data:") grid = QtWidgets.QGridLayout() box.setLayout(grid) layout.addWidget(box) self.key = parent.key self.name_label = QtWidgets.QLabel("Name:") self.name = QtWidgets.QLineEdit() grid.addWidget(self.name_label, 0, 0) grid.addWidget(self.name, 0, 1) self.amount_label = QtWidgets.QLabel("Amount:") self.amount = QtWidgets.QLineEdit() locale = QtCore.QLocale(QtCore.QLocale.English) locale.setNumberOptions(QtCore.QLocale.RejectGroupSeparator) validator = QtGui.QDoubleValidator() validator.setLocale(locale) self.amount.setValidator(validator) grid.addWidget(self.amount_label, 1, 0) grid.addWidget(self.amount, 1, 1) self.database_label = QtWidgets.QLabel("Database:") self.database = QtWidgets.QComboBox() grid.addWidget(self.database_label, 2, 0) grid.addWidget(self.database, 2, 1) # Register fields for all possible values self.registerField("name*", self.name) self.registerField("amount", self.amount) self.registerField("database", self.database, "currentText")
def __init__(self, node, attr, label='', parent=None): ''' Initialize ''' super(NumWidget, self).__init__(node, attr, label, parent) ######################################################################## #Widgets ######################################################################## #: The QLineEdit storing the value of the attribute self.valLE = QtWidgets.QLineEdit(parent=self) #Set a validator for the valLE that will ensure that the user may only #enter numerical values self.valLE.setValidator(QtGui.QDoubleValidator(self.valLE)) ######################################################################## #Layout ######################################################################## self.layout.addWidget(self.valLE) self.layout.addStretch(1) ######################################################################## #Connections ######################################################################## #We need to call the callUpdateAttr method whenever the user modifies the #value in valLE self.connect(self.valLE, QtCore.SIGNAL("editingFinished()"), self.callUpdateAttr) ######################################################################## #Set the initial node ######################################################################## self.setNode(node)
def __init__(self, parent=None, **kwargs): super(EditableLabel, self).__init__(parent=parent, **kwargs) self.is_editable = kwargs.get("editable", True) self.keyPressHandler = KeyPressHandler(self) self.setStyleSheet(styles.CONTROL_VALUE) self.mainLayout = QtWidgets.QHBoxLayout(self) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.setObjectName("mainLayout") self.label = QtWidgets.QLabel(self) self.label.setObjectName("label") # self.label.setStyleSheet(styles.CONTROL_VALUE) self.label.setMinimumHeight(styles.VALUE_SIZE) self.mainLayout.addWidget(self.label) self.lineEdit = QtWidgets.QLineEdit(self) # self.lineEdit.setSizePolicy(QtWidgets.QSizePolicy.Expanding, # QtWidgets.QSizePolicy.Expanding) # self.lineEdit.setMinimumHeight(styles.VALUE_SIZE) self.lineEdit.setObjectName("lineEdit") self.lineEdit.setValidator(QtGui.QDoubleValidator()) self.mainLayout.addWidget(self.lineEdit) # hide the line edit initially self.lineEdit.setHidden(True) # setup signals self.create_signals()
def __init__(self, type=INT, default=0, minimum=None, maximum=None, parent=None, **kwargs): super(DragLine, self).__init__(parent) self.setToolTip( "Hold and drag middle mouse button to adjust the value\n" "(Hold CTRL or SHIFT change rate)") if type == INT: self.setValidator(QtGui.QIntValidator(parent=self)) else: self.setValidator(QtGui.QDoubleValidator(parent=self)) self.type = type self.minimum = minimum self.maximum = maximum self.steps = 1 self.value_at_press = None self.pos_at_press = None self.set_value(default)
def __init__(self, parent=None): super(CacheOptions, self).__init__(parent) self._verbose = QtWidgets.QCheckBox('Verbose') self._rangetype_timeline = QtWidgets.QRadioButton('Timeline') self._rangetype_custom = QtWidgets.QRadioButton('Custom range') self._rangetype = QtWidgets.QButtonGroup() self._rangetype.addButton(self._rangetype_timeline, 0) self._rangetype.addButton(self._rangetype_custom, 1) self._rangein = QtWidgets.QLineEdit('0') self._rangein.setMaxLength(5) self._rangein.setFixedWidth(60) self._rangein.setValidator(QtGui.QIntValidator()) self._rangeout = QtWidgets.QLineEdit('100') self._rangeout.setMaxLength(5) self._rangeout.setFixedWidth(60) self._rangeout.setValidator(QtGui.QIntValidator()) self._behavior_clear = QtWidgets.QRadioButton(BLENDMODE_LABELS[0]) self._behavior_blend = QtWidgets.QRadioButton(BLENDMODE_LABELS[1]) self._behavior_force_blend = QtWidgets.QRadioButton(BLENDMODE_LABELS[2]) self._behavior = QtWidgets.QButtonGroup() self._behavior.addButton(self._behavior_clear, 0) self._behavior.addButton(self._behavior_blend, 1) self._behavior.addButton(self._behavior_force_blend, 2) self._samples_evaluated = QtWidgets.QLineEdit() self._samples_evaluated.setValidator(QtGui.QDoubleValidator()) self._samples_evaluated.setFixedWidth(60) self._samples_recorded = QtWidgets.QLineEdit() self._samples_recorded.setValidator(QtGui.QIntValidator()) self._samples_recorded.setFixedWidth(60) self._custom_range = QtWidgets.QWidget() self._range_layout = QtWidgets.QHBoxLayout(self._custom_range) self._range_layout.addWidget(self._rangein) self._range_layout.addWidget(self._rangeout) self._range_layout.addStretch(1) self.layout = QtWidgets.QFormLayout(self) self.layout.setSpacing(0) self.layout.addRow("", self._verbose) self.layout.addItem(QtWidgets.QSpacerItem(10, 10)) self.layout.addRow("Range: ", self._rangetype_timeline) self.layout.addRow("", self._rangetype_custom) self.layout.addRow("", self._custom_range) self.layout.addItem(QtWidgets.QSpacerItem(10, 10)) self.layout.addRow("Attach method: ", self._behavior_clear) self.layout.addRow("", self._behavior_blend) self.layout.addRow("", self._behavior_force_blend) self.layout.addItem(QtWidgets.QSpacerItem(10, 10)) self.layout.addRow("Evaluation sample: ", self._samples_evaluated) self.layout.addRow("Save every evaluation(s): ", self._samples_recorded) self.set_optionvars() self.update_ui_states() self._verbose.stateChanged.connect(self.save_optionvars) self._rangetype.buttonToggled.connect(self.save_optionvars) self._rangetype.buttonToggled.connect(self.update_ui_states) self._behavior.buttonToggled.connect(self.save_optionvars) self._samples_evaluated.textEdited.connect(self.save_optionvars) self._samples_recorded.textEdited.connect(self.save_optionvars)
def initUi(self): self.canSetFocusOnInput = True self.setFocusPolicy(qc.Qt.NoFocus) self.returnPressed.connect(self.clearFocus) self.setCursor(qc.Qt.SplitHCursor) self.setMouseTracking(0) self.setText("0.0") self.setValidator(qg.QDoubleValidator())
def createEditor(self, parent, option, index): editor = QtWidgets.QLineEdit(parent) locale = QtCore.QLocale(QtCore.QLocale.English) locale.setNumberOptions(QtCore.QLocale.RejectGroupSeparator) validator = QtGui.QDoubleValidator() validator.setLocale(locale) editor.setValidator(validator) return editor
def __init__(self, parent, main, app: FastFlixApp, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.main = main self.app = app self.widgets = Box() self.labels = Box() self.opts = Box() self.only_int = QtGui.QIntValidator() self.only_float = QtGui.QDoubleValidator()
def createEditor( self, parent: QtWidgets.QWidget, option: QtWidgets.QStyleOptionViewItem, index: int, ) -> QtWidgets.QWidget: # pragma: no cover lineedit = QtWidgets.QLineEdit(parent) lineedit.setValidator(QtGui.QDoubleValidator()) return lineedit
def __init__(self, minimum=None, maximum=None, parent=None): super(FloatEdit, self).__init__(parent) self.validator = QtGui.QDoubleValidator() if minimum is not None: self.validator.setBottom(minimum) if maximum is not None: self.validator.setTop(maximum) self.setValidator(self.validator) self._value = self.value() self.returnPressed.connect(self.apply)
def tipoFloat(self, valor: float = 0.0, from_sq: float = 0.0, to_sq: float = 36000.0, decimales: int = None): """ Valida los caracteres suponiendo que es un tipo decimal con unas condiciones @param valor: valor inicial @param from_sq: valor minimo @param to_sq: valor maximo @param decimales: num. decimales """ if from_sq is None: self.setValidator(QtGui.QDoubleValidator(self)) else: if decimales is None: decimales = self.decimales else: self.decimales = decimales self.setValidator(QtGui.QDoubleValidator(from_sq, to_sq, decimales, self)) self.setAlignment(QtCore.Qt.AlignRight) self.ponFloat(valor) return self
def __init__(self, text, setFixed=False, width=0, alignment=QtCore.Qt.AlignRight, parent=None): super(FloatEdit, self).__init__(parent) self.setAlignment(alignment) if(setFixed): self.setFixedWidth(width) self.validator = QtGui.QDoubleValidator() self.setText(text) self.setValidator(self.validator) self._value = self.value() self.returnPressed.connect(self.apply)
def int_validator(self, pixel_input): """ Validates size input fields Args: pixel_input: Bool value - is "pixel" selected in drop down list? """ if pixel_input: width_validator = QtGui.QIntValidator(1.0, 9999.0, self.preview_width_box) height_validator = QtGui.QIntValidator(1.0, 9999.0, self.preview_height_box) else: width_validator = QtGui.QDoubleValidator(0.0, 9999.0, 2, self.preview_width_box) height_validator = QtGui.QDoubleValidator(0.0, 9999.0, 2, self.preview_height_box) self.preview_width_box.setValidator(width_validator) self.preview_height_box.setValidator(height_validator)
def _setupDialog(self): for m in self._distModes: self._ui.comboBoxDistanceMode.addItem(m) self._ui.lineEditXTol.setValidator(QtGui.QDoubleValidator()) self._ui.spinBoxPCsToFit.setSingleStep(1) self._ui.spinBoxSurfDisc.setSingleStep(1) self._ui.doubleSpinBoxMWeight.setSingleStep(0.1) self._ui.spinBoxMaxfev.setMaximum(10000) self._ui.spinBoxMaxfev.setSingleStep(100) self._ui.spinBoxNCP.setSingleStep(1)
def __init__(self, parent=None): super(ValuesBuilder, self).__init__(parent, QtCore.Qt.Tool) self.setWindowTitle(VALUES_BUIDLER_NAME) self._start_value = QtWidgets.QLineEdit() self._start_value.setValidator(QtGui.QDoubleValidator()) self._end_value = QtWidgets.QLineEdit() self._end_value.setValidator(QtGui.QDoubleValidator()) self._iterations = QtWidgets.QLineEdit() self._iterations.setText("3") validator = QtGui.QIntValidator() validator.setBottom(3) self._iterations.setValidator(validator) self.ok = QtWidgets.QPushButton("ok") self.ok.released.connect(self.accept) self.layout = QtWidgets.QFormLayout(self) self.layout.addRow("Start value", self._start_value) self.layout.addRow("End value", self._end_value) self.layout.addRow("Iteration", self._iterations) self.layout.addWidget(self.ok)
def validaCampos(self): # Setando Validadot Int nos campos validaInt = QtGui.QIntValidator(0, 9999) self.tx_QntdItem.setValidator(validaInt) self.tx_IdBuscaItem.setValidator(validaInt) self.tx_Id.setValidator(validaInt) # Setando Validador float nos campos validarValor = QtGui.QDoubleValidator(0.00, 999.99, 2) validarValor.setNotation(QtGui.QDoubleValidator.StandardNotation) validarValor.setDecimals(2) self.tx_Desconto.setValidator(validarValor) self.tx_Frete.setValidator(validarValor)
def create_widgets(self): self.button_get = QtWidgets.QPushButton("Get TD") self.button_set = QtWidgets.QPushButton("Set TD Uniformly") self.label_td = QtWidgets.QLabel("Texel Density: ") self.label_map_size = QtWidgets.QLabel("Map Size: ") self.lineedit_td = QtWidgets.QLineEdit("0.0000") self.lineedit_td.setValidator(QtGui.QDoubleValidator()) self.lineedit_map_size = QtWidgets.QLineEdit("512") self.lineedit_map_size.setFixedWidth(45) self.lineedit_map_size.setValidator(QtGui.QIntValidator())
def validatorChanged(self, index): if index == 0: self.validatorLineEdit.setValidator(None) elif index == 1: self.validatorLineEdit.setValidator( QtGui.QIntValidator(self.validatorLineEdit)) elif index == 2: self.validatorLineEdit.setValidator( QtGui.QDoubleValidator(-999.0, 999.0, 2, self.validatorLineEdit)) self.validatorLineEdit.clear()
def setSliderValue(self): if self.valueType=='float': onlyFloat = QtGui.QDoubleValidator(self.min,self.max,2) self.lineEdit.setValidator(onlyFloat) value=round(self.attr.get(), 2) self.slider.setSingleStep(0.1) elif self.valueType=='int': onlyInt = QtGui.QIntValidator(self.min,self.max) self.lineEdit.setValidator(onlyInt) value=self.attr.get() self.lineEdit.setText(str(value)) self.slider.setValue(value) self.lineEdit.textChanged.connect(self.connectLineEditToSlider) self.slider.valueChanged.connect(self.connectSliderToLineEdit) self.checkOverride()
def __init__(self, parent): self.currvalue = 0.0 super().__init__(parent=parent) self.slider = painterslider.PainterSlider(self) self.slider.setOrientation(QtCore.Qt.Orientation.Horizontal) self.lineEdit = painterlineedit.PainterLineEdit(self) self.lineEdit.setValidator(QtGui.QDoubleValidator()) self.lineEdit.setFixedWidth(50) self.lineEdit.setFixedHeight(16) hlayout = QtWidgets.QHBoxLayout() hlayout.addWidget(self.slider) hlayout.addWidget(self.lineEdit) self.setLayout(hlayout) self.lineEdit.textEdited.connect(self._linkEditValue) self.slider.sliderMoved.connect(self._linkSliderValue)
def setSliderValue(self): if self.valueType=='float': onlyFloat = QtGui.QDoubleValidator(self.textMin,self.textMax,2) self.lineEdit.setValidator(onlyFloat) value=round(self.attr.get(), 2) elif self.valueType=='int': onlyInt = QtGui.QIntValidator(self.textMin,self.textMax) self.lineEdit.setValidator(onlyInt) value=self.attr.get() self.lineEdit.setText(str(value)) num=int((value-self.textMin)/self.textGrp*self.sliderGap+self.sliderMin) self.slider.setValue(num) self.lineEdit.textChanged.connect(self.connectLineEditToSlider) self.slider.valueChanged.connect(self.connectSliderToLineEdit) self.checkOverride()
def __init__(self, parent=None): super(DialogCreateNewAccount, self).__init__(parent) self.setupUi(self) self.parent = parent self.comboCurrency.addItems(services_gui.valid_currencies()) # set the line edit so it only accepts double values dvBalance = QtGui.QDoubleValidator(0.0, 10.0**100, 2, self.inputInitialBalance) dvBalance.setNotation(QtGui.QDoubleValidator.StandardNotation) self.inputInitialBalance.setValidator(dvBalance) # Connect add button with a custom function (addAcc) self.buttonAddNewAccount.clicked.connect(self.add_acc)