Python PyQt5.QtGui.QDoubleValidator() Examples

The following are 11 code examples for showing how to use PyQt5.QtGui.QDoubleValidator(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may want to check out the right sidebar which shows the related API usage.

You may also want to check out all available functions/classes of the module PyQt5.QtGui , or try the search function .

Example 1
Project: Pythonic   Author: hANSIc99   File: binance_order.py    License: GNU General Public License v3.0 6 votes vote down vote up
def stopLoss(self):

        logging.debug('BinanceOrder::stopLoss() called')

        self.stop_loss_input = QWidget()
        self.stop_loss_layout = QVBoxLayout(self.stop_loss_input)

        self.stop_loss_price_txt = QLabel()
        self.stop_loss_price_txt.setText(QC.translate('', 'Stop price:'))

        self.stop_loss_price_input = QLineEdit()
        self.stop_loss_price_input.setValidator(QDoubleValidator(999999, -999999, 8))

        self.stop_loss_params = QLabel()
        self.stop_loss_params.setText(
                '{\'stopPrice\' : 12.345, \'quantity\' : 0.005}')


        self.stop_loss_layout.addWidget(self.stop_loss_price_txt)
        self.stop_loss_layout.addWidget(self.stop_loss_price_input)
        self.stop_loss_layout.addWidget(self.stop_loss_params)
        self.stop_loss_layout.addStretch(1)

        self.order_box.addWidget(self.stop_loss_input) 
Example 2
Project: Pythonic   Author: hANSIc99   File: binance_order.py    License: GNU General Public License v3.0 6 votes vote down vote up
def takeProfit(self):

        logging.debug('BinanceOrder::takeProfit() called')

        self.take_profit_input = QWidget()
        self.take_profit_layout = QVBoxLayout(self.take_profit_input)

        self.take_profit_stop_price = QLabel()
        self.take_profit_stop_price.setText(QC.translate('', 'Stop price:'))

        self.take_profit_stop_price_input = QLineEdit()
        self.take_profit_stop_price_input.setValidator(QDoubleValidator(999999, -999999, 8))

        self.take_profit_params = QLabel()
        self.take_profit_params.setText(
                '{\'stopPrice\': 12.345, \'quantity\' : 0.005}')


        self.take_profit_layout.addWidget(self.take_profit_stop_price)
        self.take_profit_layout.addWidget(self.take_profit_stop_price_input)
        self.take_profit_layout.addWidget(self.take_profit_params)
        self.take_profit_layout.addStretch(1)

        self.order_box.addWidget(self.take_profit_input) 
Example 3
Project: pychemqt   Author: jjgomera   File: delegate.py    License: GNU General Public License v3.0 5 votes vote down vote up
def createEditor(self, parent, option, index):
        widget = QtWidgets.QLineEdit(parent)
        widget.setAlignment(QtCore.Qt.AlignRight)
        validator = QtGui.QDoubleValidator(self)
        locale = QtCore.QLocale("en")
        validator.setLocale(locale)
        widget.setValidator(validator)
        return widget 
Example 4
Project: eddy   Author: danielepantaleone   File: fields.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        """
        Initialize the float input field.
        """
        super().__init__(*args, **kwargs)
        self.setAttribute(QtCore.Qt.WA_MacShowFocusRect, 0)
        self.setValidator(QtGui.QDoubleValidator(self)) 
Example 5
Project: spimagine   Author: maweigert   File: test_floatslider.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self):
        super(MainWindow,self).__init__()

        self.slide = FloatSlider(QtCore.Qt.Vertical)
        self.slide.setRange(-12.,10.,400)
        self.slide.valueChanged.connect(self.onSlide)
        self.slide.floatValueChanged.connect(self.onSlideFloat)


        self.slide.setValue(7.)
        self.setWindowTitle("Key Frame View")


        self.edit = QtWidgets.QLineEdit("")
        self.edit.setValidator(QtGui.QDoubleValidator())
        self.edit.returnPressed.connect(lambda: self.slide.setValue(float(self.edit.text())))


        self.slide.floatValueChanged.connect(lambda x: self.edit.setText(str(x)))



        self.resize(500,200)
        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(self.slide)
        hbox.addWidget(self.edit)

        self.setLayout(hbox)

        # self.setStyleSheet("""
        #    background-color:black;
        #    color:black;""") 
Example 6
Project: Pythonic   Author: hANSIc99   File: binance_order.py    License: GNU General Public License v3.0 5 votes vote down vote up
def limitOrder(self):

        logging.debug('BinanceOrder::limitOrder() called')

        self.limit_input = QWidget()
        self.limit_layout = QVBoxLayout(self.limit_input)

        self.limit_time_in_force_txt = QLabel()
        self.limit_time_in_force_txt.setText(QC.translate('', 'Time in force:'))

        self.limit_time_in_force_input = QComboBox()
        self.limit_time_in_force_input.addItem(QC.translate('',
            'Good til canceled'), QVariant('GTC'))
        self.limit_time_in_force_input.addItem(QC.translate('',
            'Immediate or Cancel'), QVariant('IOC'))
        self.limit_time_in_force_input.addItem(QC.translate('', 'Fill or Kill'), QVariant('FOK'))

        self.limit_price_txt = QLabel()
        self.limit_price_txt.setText(QC.translate('', 'Limit price:'))

        self.limit_price_input = QLineEdit()
        self.limit_price_input.setValidator(QDoubleValidator(999999, -999999, 8))

        self.limit_input_params = QLabel()
        self.limit_input_params.setText(
                '{\'price\' : 12.345, \'quantity\' : 0.005, \'type\' : \'GTC\'/\'IOC\'/\'FOK\'}')

        self.limit_layout.addWidget(self.limit_time_in_force_txt)
        self.limit_layout.addWidget(self.limit_time_in_force_input)
        self.limit_layout.addWidget(self.limit_price_txt)
        self.limit_layout.addWidget(self.limit_price_input)
        self.limit_layout.addWidget(self.limit_input_params)


        self.order_box.addWidget(self.limit_input) 
Example 7
Project: quick   Author: szsdk   File: quick.py    License: GNU General Public License v3.0 5 votes vote down vote up
def to_widget(self, opt):
        return GStringLineEditor.to_widget(self, opt,
                validator=QtGui.QDoubleValidator()) 
Example 8
Project: quick   Author: szsdk   File: quick.py    License: GNU General Public License v3.0 5 votes vote down vote up
def select_type_validator(tp: click.types.ParamType)-> QtGui.QValidator:
    """ select the right validator for `tp`"""
    if isinstance(tp, click.types.IntParamType):
        return QtGui.QIntValidator()
    elif isinstance(tp, click.types.FloatParamType):
        return QtGui.QDoubleValidator()
    return None 
Example 9
Project: spimagine   Author: maweigert   File: imageprocessor_view.py    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def initUI(self):
        if self.proc is None:
            return


        # def createStandardCheckbox(parent, img1=None , img2 = None, tooltip = ""):

        vbox = QtWidgets.QVBoxLayout()

        gridBox = QtWidgets.QGridLayout()

        self.checkActive = gui_utils.createImageCheckbox(self,
                                                         absPath("images/icon_processor_active"),
                                                         absPath("images/icon_processor_inactive"))


        label = QtWidgets.QLabel(self.proc.name)

        gridBox.addWidget(self.checkActive,0,0)

        gridBox.addWidget(label,0,1)

        for i, (key, val)  in enumerate(six.iteritems(self.proc.kwargs)):
            dtype = type(val)
            if dtype == bool:
                check = QtWidgets.QCheckBox("",self)
                check.stateChanged.connect(self.set_proc_attr_check(check,key,val))
                gridBox.addWidget(QtWidgets.QLabel(key),i+1,0)
                gridBox.addWidget(check,i+1,1)

            elif dtype in (int,float,np.int,np.float):
                edit = QtWidgets.QLineEdit(str(val))
                edit.setValidator(QtGui.QDoubleValidator())
                edit.returnPressed.connect(self.set_proc_attr_edit(edit,key,dtype))
                gridBox.addWidget(QtWidgets.QLabel(key),i+1,0)
                gridBox.addWidget(edit,i+1,1)

        vbox.addLayout(gridBox)
        vbox.addStretch()

        self.setLayout(vbox)
        self.setSizePolicy(Qt.QSizePolicy.Minimum,Qt.QSizePolicy.Minimum)
        self.setStyleSheet("""
        QFrame,QLabel,QLineEdit {
        color: white;
        }
        """)

        self.checkActive.stateChanged.connect(lambda x:self._stateChanged.emit(x!=0))
        # self._stateChanged.connect(self.foo) 
Example 10
Project: Pythonic   Author: hANSIc99   File: binance_order.py    License: GNU General Public License v3.0 4 votes vote down vote up
def stopLossLimit(self):

        logging.debug('BinanceOrder::stopLossLimit() called')

        self.stop_loss_limit_input = QWidget()
        self.stop_loss_limit_layout = QVBoxLayout(self.stop_loss_limit_input)

        self.stop_loss_limit_time_in_force_txt = QLabel()
        self.stop_loss_limit_time_in_force_txt.setText(QC.translate('', 'Time in force:'))

        self.stop_loss_limit_time_in_force_input = QComboBox()
        self.stop_loss_limit_time_in_force_input.addItem(QC.translate('',
            'Good til canceled'), QVariant('GTC'))
        self.stop_loss_limit_time_in_force_input.addItem(QC.translate('',
            'Immediate or Cancel'), QVariant('IOC'))
        self.stop_loss_limit_time_in_force_input.addItem(QC.translate('',
            'Fill or Kill'), QVariant('FOK'))


        self.stop_loss_limit_price_txt = QLabel()
        self.stop_loss_limit_price_txt.setText(QC.translate('', 'Price:'))

        self.stop_loss_limit_price_input = QLineEdit()
        self.stop_loss_limit_price_input.setValidator(QDoubleValidator(999999, -999999, 8))


        self.stop_loss_limit_stop_price_txt = QLabel()
        self.stop_loss_limit_stop_price_txt.setText(QC.translate('', 'Stop price:'))

        self.stop_loss_limit_stop_price_input = QLineEdit()
        self.stop_loss_limit_stop_price_input.setValidator(QDoubleValidator(999999, -999999, 8))

        self.stop_loss_limit_params = QLabel()
        self.stop_loss_limit_params.setText(
                '{\'price\' : 12.345, \'stopPrice\': 12.345, \'quantity\' : 0.005, \'type\' : \'GTC\'/\'IOC\'/\'FOK\'}')

        self.stop_loss_limit_layout.addWidget(self.stop_loss_limit_time_in_force_txt)
        self.stop_loss_limit_layout.addWidget(self.stop_loss_limit_time_in_force_input)
        self.stop_loss_limit_layout.addWidget(self.stop_loss_limit_price_txt)
        self.stop_loss_limit_layout.addWidget(self.stop_loss_limit_price_input)
        self.stop_loss_limit_layout.addWidget(self.stop_loss_limit_stop_price_txt)
        self.stop_loss_limit_layout.addWidget(self.stop_loss_limit_stop_price_input)
        self.stop_loss_limit_layout.addWidget(self.stop_loss_limit_params)

        self.order_box.addWidget(self.stop_loss_limit_input) 
Example 11
Project: Pythonic   Author: hANSIc99   File: binance_order.py    License: GNU General Public License v3.0 4 votes vote down vote up
def takeProfitLimit(self):

        logging.debug('BinanceOrder::takeProfitLimit() called')

        self.take_profit_limit_input = QWidget()
        self.take_profit_limit_layout = QVBoxLayout(self.take_profit_limit_input)

        self.take_profit_limit_time_in_force_txt = QLabel()
        self.take_profit_limit_time_in_force_txt.setText(QC.translate('', 'Time in force:'))

        self.take_profit_limit_time_in_force_input = QComboBox()
        self.take_profit_limit_time_in_force_input.addItem(QC.translate('',
            'Good til canceled'), QVariant('GTC'))
        self.take_profit_limit_time_in_force_input.addItem(QC.translate('',
            'Immediate or Cancel'), QVariant('IOC'))
        self.take_profit_limit_time_in_force_input.addItem(QC.translate('',
            'Fill or Kill'), QVariant('FOK'))

        self.take_profit_limit_price = QLabel()
        self.take_profit_limit_price.setText(QC.translate('', 'Price:'))

        self.take_profit_limit_price_input = QLineEdit()
        self.take_profit_limit_price_input.setValidator(QDoubleValidator(999999, -999999, 8))


        self.take_profit_limit_stop_price = QLabel()
        self.take_profit_limit_stop_price.setText(QC.translate('', 'Stop price:'))

        self.take_profit_limit_stop_price_input = QLineEdit()
        self.take_profit_limit_stop_price_input.setValidator(QDoubleValidator(999999, -999999, 8))

        self.take_profit_limit_params = QLabel()
        self.take_profit_limit_params.setText(
                '{\'price\' : 12.345, \'stopPrice\': 12.345, \'quantity\' : 0.005, \'type\' : \'GTC\'/\'IOC\'/\'FOK\'}')

        self.take_profit_limit_layout.addWidget(self.take_profit_limit_time_in_force_txt)
        self.take_profit_limit_layout.addWidget(self.take_profit_limit_time_in_force_input)
        self.take_profit_limit_layout.addWidget(self.take_profit_limit_price)
        self.take_profit_limit_layout.addWidget(self.take_profit_limit_price_input)
        self.take_profit_limit_layout.addWidget(self.take_profit_limit_stop_price)
        self.take_profit_limit_layout.addWidget(self.take_profit_limit_stop_price_input)
        self.take_profit_limit_layout.addWidget(self.take_profit_limit_params)

        self.order_box.addWidget(self.take_profit_limit_input)