Python PyQt5.QtGui.QRegExpValidator() Examples

The following are code examples for showing how to use PyQt5.QtGui.QRegExpValidator(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: openocd-svd   Author: esynr3z   File: ui_widgets.py    MIT License 6 votes vote down vote up
def setDisplayValidator(self, base):
        if base == 10:
            max_int = 2**self.numBitWidth()
            self.setValidator(QIntValidator(0, max_int - 1))
        elif base == 16:
            high_part = ""
            low_part = ""
            if self.numBitWidth() % 4 > 0:
                high_part = "[0-%d]" % (2**(self.numBitWidth() % 4) - 1)
            if int(self.numBitWidth() / 4) > 0:
                low_part = "[0-9A-Fa-f]{%d}" % int(self.numBitWidth() / 4)
            allowed_symbols = "0x" + high_part + low_part
            self.setValidator(QRegExpValidator(QtCore.QRegExp(allowed_symbols)))
        elif base == 2:
            high_part = ""
            low_part = ""
            if self.numBitWidth() % 4 > 0:
                high_part = "(0|1){%d}" % (self.numBitWidth() % 4)
            if int(self.numBitWidth() / 4) > 0:
                low_part = "((\s|)(0|1){4}){%d}" % int(self.numBitWidth() / 4)
            allowed_symbols = "^" + high_part + low_part + "$"
            self.setValidator(QRegExpValidator(QtCore.QRegExp(allowed_symbols))) 
Example 2
Project: Frevo   Author: matuzalemmuller   File: preferences.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, tray):
        super().__init__()
        self._tray = tray
        self.setWindowTitle("Preferences")
        validator=QtCore.QRegExp("[A-Za-z0-9- _]+")
        self._nameValidator = QtGui.QRegExpValidator(validator)

        self._windowLayout = self._createLayout()
        self._windowLayout.setSizeConstraint(QLayout.SetFixedSize)
        self.setLayout(self._windowLayout)

        self.exec_()
        self.activateWindow()


    # Cancel button action 
Example 3
Project: EMFT_ARCHIVE   Author: theendsofinvention   File: base.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(
        self,
        text,
        on_text_changed: callable = None,
        read_only: bool = False,
        clear_btn_enabled: bool = False,
        validation_regex: str = None,
        set_enabled: bool = True,
    ):
        QLineEdit.__init__(self, text)
        if on_text_changed:
            # noinspection PyUnresolvedReferences
            self.textChanged.connect(on_text_changed)
        self.setReadOnly(read_only)
        self.setClearButtonEnabled(clear_btn_enabled)
        if validation_regex:
            self.setValidator(QRegExpValidator(QRegExp(validation_regex), self))
        self.setEnabled(set_enabled) 
Example 4
Project: face_recognition_py   Author: winterssy   File: dataRecord.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        super(UserInfoDialog, self).__init__()
        loadUi('./ui/UserInfoDialog.ui', self)
        self.setWindowIcon(QIcon('./icons/icon.png'))
        self.setFixedSize(425, 300)

        # 使用正则表达式限制用户输入
        stu_id_regx = QRegExp('^[0-9]{12}$')
        stu_id_validator = QRegExpValidator(stu_id_regx, self.stuIDLineEdit)
        self.stuIDLineEdit.setValidator(stu_id_validator)

        cn_name_regx = QRegExp('^[\u4e00-\u9fa5]{1,10}$')
        cn_name_validator = QRegExpValidator(cn_name_regx, self.cnNameLineEdit)
        self.cnNameLineEdit.setValidator(cn_name_validator)

        en_name_regx = QRegExp('^[ A-Za-z]{1,16}$')
        en_name_validator = QRegExpValidator(en_name_regx, self.enNameLineEdit)
        self.enNameLineEdit.setValidator(en_name_validator) 
Example 5
Project: bap-ida-python   Author: BinaryAnalysisPlatform   File: bap_trace.py    MIT License 6 votes vote down vote up
def __init__(self, parent=None):
        super(MachineSelector, self).__init__(parent)
        box = QtWidgets.QHBoxLayout(self)
        label = MonitoringLabel('List of &machines (threads)')
        self.is_ready = label.is_ready
        self.updated = label.updated
        box.addWidget(label)
        self._machines = QtWidgets.QLineEdit('all')
        self._machines.setToolTip('an integer, \
        a comma-separated list of integers, or "all"')
        grammar = QRegExp(r'\s*(all|\d+\s*(,\s*\d+\s*)*)\s*')
        valid = QtGui.QRegExpValidator(grammar)
        self._machines.setValidator(valid)
        label.setBuddy(self._machines)
        box.addWidget(self._machines)
        box.addStretch(1)
        self.setLayout(box) 
Example 6
Project: pbtk   Author: marin-m   File: fuzzer.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, min_, max_, float_=False):
        super(QwordSpinBox, self).__init__()

        self._minimum = min_
        self._maximum = max_
        self.int_ = float if float_ else int

        rx = QRegExp('-?\d{0,20}(?:\.\d{0,20})?' if float_ else '-?\d{0,20}')
        validator = QRegExpValidator(rx, self)

        self._lineEdit = QLineEdit(self)
        self._lineEdit.setText(str(self.int_(0)))
        self._lineEdit.setValidator(validator)
        self._lineEdit.textEdited.connect(partial(self.setValue, change=False))
        self.editingFinished.connect(lambda: self.setValue(self.value(), update=False) or True)
        self.setLineEdit(self._lineEdit) 
Example 7
Project: Pythonic   Author: hANSIc99   File: basic_sched.py    GNU General Public License v3.0 6 votes vote down vote up
def at_time(self):

        logging.debug('at_time() called')

        self.at_time_input = QWidget()
        self.at_time_layout = QVBoxLayout(self.at_time_input)

        self.time_text = QLabel()
        self.time_text.setText(QC.translate('', 'At:'))

        self.time_input = QLineEdit()
        regexp_validator = QRegExp('^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$')
        self.time_validator = QRegExpValidator(regexp_validator)
        self.time_input.setValidator(self.time_validator)
        self.time_input.setPlaceholderText(QC.translate('', 'hh:mm'))

        self.at_time_layout.addWidget(self.time_text)
        self.at_time_layout.addWidget(self.time_input)

        self.at_time_input.hide()
        self.options_box_layout.addWidget(self.at_time_input) 
Example 8
Project: USBIPManager   Author: lompal   File: ModalAddServer.py    MIT License 6 votes vote down vote up
def __init__(self, parent=None):
        # noinspection PyArgumentList
        super(AddServerUI, self).__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        uic.loadUi("ui/ModalAddServer.ui", self)

        # Getting the configuration from config.ini file
        self.config = config.get_config()
        #
        self.server_port.setText(self.config["SETTINGS"]["server_default_port"])
        self.search_filter.setText("*")

        # Obligatory line edit list
        self.linedit_list = [self.server_address, self.server_port, self.search_filter]
        #
        for linedit in self.linedit_list:
            linedit.textChanged.connect(partial(text_changed, linedit))

        # Setting IP validation for server address line edit
        ip_validator = QRegExpValidator(config.ip_regex, self)
        self.server_address.setValidator(ip_validator)

        #
        self.apply_button.clicked.connect(self.apply_action)
        self.cancel_button.clicked.connect(self.close) 
Example 9
Project: MeiTingTrunk   Author: Xunius   File: folder_tree.py    GNU General Public License v3.0 5 votes vote down vote up
def createEditor(self, parent, option, index):
        '''To disable typing in invalid chars in the folder name'''

        editor = QtWidgets.QLineEdit(parent)
        reg=QtCore.QRegExp('[A-z0-9\[\]_-\s]+')
        vd=QRegExpValidator(reg)
        editor.setValidator(vd)

        return editor 
Example 10
Project: data-structure   Author: yunowo   File: common.py    GNU General Public License v3.0 5 votes vote down vote up
def search_validator():
    return QRegExpValidator(QRegExp('[\w.\'" ()]+')) 
Example 11
Project: beqdesigner   Author: 3ll3d00d   File: delegates.py    MIT License 5 votes vote down vote up
def createEditor(self, widget, option, index):
        if not index.isValid():
            return 0
        if index.column() == 0:  # only on the cells in the first column
            editor = QLineEdit(widget)
            validator = QRegExpValidator(QRegExp(self.__regex), editor)
            editor.setValidator(validator)
            return editor
        return super(RegexValidator, self).createEditor(widget, option, index) 
Example 12
Project: EMFT_ARCHIVE   Author: theendsofinvention   File: base.py    GNU General Public License v3.0 5 votes vote down vote up
def createEditor(self, parent: QWidget, style: QStyleOptionViewItem, index: QModelIndex):  # noqa: N802
            editor = QLineEdit(parent)
            if self._regex:
                validator = QRegExpValidator(editor)
                validator.setRegExp(QRegExp(self._regex))
                editor.setValidator(validator)
            editor.setText(str(index.data(Qt.DisplayRole)))
            return editor 
Example 13
Project: taskcounter   Author: ardeidae   File: durationedit.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent=None, hour_length=2):
        """Construct a duration edit."""
        super().__init__(parent)
        self._hour_length = hour_length
        regexp = QRegExp(
            '^[0-9]{1,' + str(self._hour_length) + '}:[0-5]{,1}[0-9]?$')
        self._validator = QRegExpValidator(regexp)
        self._minutes = 0
        self.lineEdit().textChanged.connect(self.text_changed) 
Example 14
Project: face_recognition_py   Author: winterssy   File: core.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        super(TelegramBotDialog, self).__init__()
        loadUi('./ui/TelegramBotDialog.ui', self)
        self.setWindowIcon(QIcon('./icons/icon.png'))
        self.setFixedSize(550, 358)

        chat_id_regx = QRegExp('^\d+$')
        chat_id_validator = QRegExpValidator(chat_id_regx, self.telegramIDLineEdit)
        self.telegramIDLineEdit.setValidator(chat_id_validator)

        self.okButton.clicked.connect(self.telegramBotSettings) 
Example 15
Project: sane-subfeed   Author: BluABK   File: config_view.py    GNU Affero General Public License v3.0 5 votes vote down vote up
def add_config_tab_gui(self):
        self.add_option_line_edit('Videos to load by default', 'Model', 'loaded_videos',
                                  cfg_validator=QIntValidator())
        self.add_option_checkbox('Grey background on old (1d+) videos', 'Gui', 'grey_old_videos')
        self.add_option_line_edit('Grid tile height (px)', 'Gui', 'tile_pref_height', cfg_validator=QIntValidator())
        self.add_option_line_edit('Grid tile width (px)', 'Gui', 'tile_pref_width', cfg_validator=QIntValidator())
        self.add_option_line_edit('Grid tile overlay height (%)', 'Gui', 'tile_overlay_height_pct',
                                  cfg_validator=QIntValidator())
        self.add_option_line_edit('Grid tile overlay width (%)', 'Gui', 'tile_overlay_width_pct',
                                  cfg_validator=QIntValidator())
        self.add_option_checkbox('Embed thumbnails in tooltips', 'Gui', 'tooltip_pictures')
        tooltip_thumb_disabled = not read_config('Gui', 'tooltip_pictures')
        self.add_option_line_edit('\tTooltip picture width', 'Gui', 'tooltip_picture_width',
                                  cfg_validator=QIntValidator(), disabled=tooltip_thumb_disabled)
        self.add_option_line_edit('\tTooltip picture height', 'Gui', 'tooltip_picture_height',
                                  cfg_validator=QIntValidator(), disabled=tooltip_thumb_disabled)
        self.add_option_combobox('\tTooltip picture font size', 'Gui', 'tooltip_picture_size',
                                 TT_FONT_SIZES, disabled=tooltip_thumb_disabled)
        self.add_option_checkbox('Keep Aspect Ratio on resized thumbnails', 'Gui', 'keep_thumb_ar', restart_check=False)
        self.add_option_checkbox('Auto copy to clipboard', 'Gui', 'enable_auto_copy_to_clipboard', restart_check=False)
        self.add_section('{}Theme{}'.format(self.deco_l, self.deco_r))
        self.add_option_line_edit('Set custom background color hexadecimal <br/>'
                                  '(only works in default theme. Ex: #ffffff for white bg)',
                                  'Gui', 'bgcolor',
                                  cfg_validator=QRegExpValidator(QRegExp(HEXADECIMAL_COLOR_REGEX)))
        self.add_option_button('Clear bgcolor', 'Clears the background color setting ', 'Gui', 'bgcolor',
                               tooltip='(required due to validator shenanigans)', clear=True)
        self.add_option_checkbox('Use darkmode icon set', 'Gui', 'darkmode_icons')
        self.add_option_line_edit('Toolbar icon size modifier (Useful on High DPI displays)',
                                  'Gui', 'toolbar_icon_size_modifier', actions=[self.root.update_toolbar_size,
                                                                                self.root.respawn_menubar_and_toolbar])
        self.add_option_info_restart_required() 
Example 16
Project: sane-subfeed   Author: BluABK   File: main_window.py    GNU Affero General Public License v3.0 5 votes vote down vote up
def download_single_url_dialog(self):
        """
        Prompts user for downloading a video by URL/ID
        :return:
        """
        input_dialog = SaneInputDialog(self, self.main_model.main_window_listener.getSingleVideo.emit,
                                       title='Download a video by URL/ID',
                                       text='Enter a YouTube URL or ID', ok_text='Download',
                                       validator=QRegExpValidator(YOUTUBE_URL_REGEX))
        input_dialog.show() 
Example 17
Project: cognitive-battery   Author: sho-87   File: project_new_window.py    MIT License 5 votes vote down vote up
def __init__(self, base_dir, project_list):
        super(NewProjectWindow, self).__init__()

        # Setup the main window UI
        self.setupUi(self)

        # Set app icon
        self.setWindowIcon(QtGui.QIcon(os.path.join("images", "icon_sml.png")))

        # Delete the object when dialog is closed
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        # Remove the help / whats this button from title bar
        self.setWindowFlags(self.windowFlags() ^ QtCore.Qt.WindowContextHelpButtonHint)

        self.project_list = project_list
        self.base_dir = base_dir

        # Set input validators
        self.projectNameValue.setValidator(
            QtGui.QRegExpValidator(QtCore.QRegExp("[A-Za-z0-9 ]+"))
        )

        # Bind button events
        self.dirSelectButton.clicked.connect(self.select_file)
        self.createButton.clicked.connect(self.create_project)
        self.cancelButton.clicked.connect(self.close) 
Example 18
Project: life-exam   Author: valueerrorx   File: client.py    GNU General Public License v3.0 5 votes vote down vote up
def _initUi(self):
        self.scriptdir=os.path.dirname(os.path.abspath(__file__))
        uifile=os.path.join(APP_DIRECTORY,'client/client.ui')
        self.ui = uic.loadUi(uifile) 
        winicon=os.path.join(APP_DIRECTORY,'pixmaps/windowicon.png')
        self.ui.setWindowIcon(QIcon(winicon))
        self.ui.exit.clicked.connect(self._onAbbrechen)  # setup Slots
        self.ui.start.clicked.connect(self._onStartExamClient)
        self.ui.offlineexam.clicked.connect(self._on_offline_exam)
        self.ui.offlineexamexit.clicked.connect(self._on_offline_exam_exit)
        self.ui.serverdropdown.currentIndexChanged.connect(self._updateIP)
        self.ui.serverdropdown.activated.connect(self._updateIP)
        self.ui.studentid.textChanged.connect(lambda: self._changePalette(self.ui.studentid, 'ok'))
        self.ui.studentid.setFocus()
        #self.ui.serverip.textChanged.connect(lambda: self._changePalette(self.ui.serverip,'ok'))
        self.ui.pincode.textChanged.connect(lambda: self._changePalette(self.ui.pincode,'ok'))
        self.ui.serverip.hide()
        self.ui.keyPressEvent = self.newOnkeyPressEvent

        char_regex=QRegExp("[a-z-A-Z\-_]+")   # only allow specif characters in textfields
        char_validator = QRegExpValidator(char_regex)
        self.ui.studentid.setValidator(char_validator)

        num_regex=QRegExp("[0-9_]+")
        num_validator = QRegExpValidator(num_regex)
        self.ui.pincode.setValidator(num_validator)

        ip_regex=QRegExp("[0-9\._]+")
        ip_validator = QRegExpValidator(ip_regex)
        #self.ui.serverip.setValidator(ip_validator) 
Example 19
Project: calculator.py   Author: stevenshuang   File: calculator.py    MIT License 5 votes vote down vote up
def ui(self):
        reg = QRegExp("^$")      # 把键盘禁用了, 仅可以按钮的输入
        validator = QRegExpValidator(reg, self)

        self.line_edit = QLineEdit('0', self)
        self.line_edit.setAlignment(Qt.AlignRight)
        self.line_edit.setValidator(validator)
        self.line_edit.setReadOnly(True)
        grid = QGridLayout()
        self.setLayout(grid)

        btn_names = [
            'C', 'None', '%', '/',
            '7', '8', '9', '*',
            '4', '5', '6', '-',
            '1', '2', '3', '+',
            '0', '', '.', '='
        ]

        grid.addWidget(self.line_edit, 0, 0, 1, 4)
        positions = [(i, j) for i in range(1, 6) for j in range(4)]
        for pos, name in zip(positions, btn_names):
            if name == '':
                continue
            btn = QPushButton(name)
            btn.clicked.connect(self.show_msg)
            if name == '0':
                tmp_pos = (pos[0], pos[1]+1) 
                grid.addWidget(btn, *pos, 1, 2)
            else:
                grid.addWidget(btn, *pos)
        self.setFocusPolicy(Qt.StrongFocus)
        self.setWindowTitle('Calculator')
        self.move(300, 150)
        self.show() 
Example 20
Project: Pythonic   Author: hANSIc99   File: basic_sched.py    GNU General Public License v3.0 5 votes vote down vote up
def time_between(self):

        logging.debug('time_between() called')
        self.time_between_input = QWidget()
        self.time_between_layout = QVBoxLayout(self.time_between_input)

        self.time_between_txt = QLabel()
        self.time_between_txt.setText(QC.translate('', 'Between'))

        regexp_validator = QRegExp('^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$')
        self.time_validator = QRegExpValidator(regexp_validator)

        self.time_row = QWidget()
        self.time_row_layout = QHBoxLayout(self.time_row)

        self.start_time_input = QLineEdit()
        self.start_time_input.setValidator(self.time_validator)
        self.start_time_input.setPlaceholderText(QC.translate('', 'hh:mm (default 00:00)'))

        self.and_text = QLabel()
        self.and_text.setText(QC.translate('', 'and'))

        self.stop_time_input = QLineEdit()
        self.stop_time_input.setValidator(self.time_validator)
        self.stop_time_input.setPlaceholderText(QC.translate('', 'hh:mm (default 00:00)'))

        
        self.time_row_layout.addWidget(self.start_time_input)
        self.time_row_layout.addWidget(self.and_text)
        self.time_row_layout.addWidget(self.stop_time_input)


        self.time_between_layout.addWidget(self.time_between_txt)
        self.time_between_layout.addWidget(self.time_row)

        self.time_between_input.hide()

        self.options_box_layout.addWidget(self.time_between_input) 
Example 21
Project: liquid-swap   Author: Blockstream   File: app.py    GNU General Public License v3.0 5 votes vote down vote up
def set_re_float(line_edit):
    line_edit.setValidator(QRegExpValidator(QRegExp('^\d*\.?\d+$'), line_edit))
# TODO: add regex also for asset id 
Example 22
Project: openspectra   Author: openspectra   File: toolsdisplay.py    Apache License 2.0 4 votes vote down vote up
def __init__(self, files:Dict[str, FileSubCubeParams], parent=None):
        super().__init__(parent)
        self.__files = files
        num_files = len(self.__files)

        layout = QVBoxLayout()
        form_layout = QFormLayout()

        self.__file_list = QComboBox(self)

        if num_files > 1:
            self.__file_list.insertItem(0, "Select origin file...")
            self.__file_list.insertItems(1, self.__files.keys())
        else:
            self.__file_list.insertItems(0, self.__files.keys())

        self.__file_list.currentIndexChanged.connect(self.__handle_file_select)
        form_layout.addRow("Original File:", self.__file_list)

        self.__file_type = QComboBox(self)
        self.__format_map = {OpenSpectraHeader.BIL_INTERLEAVE : "BIL - Band Interleaved by Line",
                             OpenSpectraHeader.BSQ_INTERLEAVE : "BSQ - Band Sequential",
                             OpenSpectraHeader.BIP_INTERLEAVE : "BIP - Band Interleaved by Pixel"}
        self.__file_type.insertItem(0, "")
        self.__file_type.insertItems(1, self.__format_map.values())
        form_layout.addRow("Output File Interleave:", self.__file_type)

        self.__sample_range = RangeSelector(self)
        form_layout.addRow("Sample Range:", self.__sample_range)

        self.__line_range = RangeSelector(self)
        form_layout.addRow("Line Range:", self.__line_range)

        self.__band_select = QLineEdit(self)
        self.__band_select.setMinimumWidth(250)
        self.__band_validator = QRegExpValidator(QRegExp("[1-9][0-9]*((-|,)([1-9][0-9]*))*"))
        self.__band_select.setValidator(self.__band_validator)
        self.__band_select.setToolTip\
                ("Use '-' for a range, ',' to separate ranges and single bands.\nExample: 1-10,12,14,19-21")
        self.__max_band = 0

        form_layout.addRow("Bands:", self.__band_select)
        layout.addLayout(form_layout)

        button_layout = QHBoxLayout()
        cancel_button = QPushButton("Cancel", self)
        cancel_button.clicked.connect(self.cancel)
        button_layout.addWidget(cancel_button)

        self.__save_button = QPushButton("Save", self)
        self.__save_button.setDisabled(True)
        self.__save_button.clicked.connect(self.__handle_save)
        button_layout.addWidget(self.__save_button)
        layout.addLayout(button_layout)
        self.setLayout(layout)

        self.__handle_file_select(0) 
Example 23
Project: rapid-gui-pyqt5   Author: paramono   File: numberformatdlg3.py    GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, format_, callback, parent=None):
        super(NumberFormatDlg, self).__init__(parent)
        punctuationRe = QRegExp(r"[ ,;:.]")

        self.thousandsEdit = QLineEdit(format_["thousandsseparator"])
        self.thousandsEdit.setMaxLength(1)
        self.thousandsEdit.setValidator(QRegExpValidator(
                punctuationRe, self))

        thousandsLabel = QLabel("&Thousands separator")
        thousandsLabel.setBuddy(self.thousandsEdit)

        self.decimalMarkerEdit = QLineEdit(format_["decimalmarker"])
        self.decimalMarkerEdit.setMaxLength(1)
        self.decimalMarkerEdit.setValidator(QRegExpValidator(
                punctuationRe, self))
        self.decimalMarkerEdit.setInputMask("X")

        decimalMarkerLabel = QLabel("Decimal &marker")
        decimalMarkerLabel.setBuddy(self.decimalMarkerEdit)

        self.decimalPlacesSpinBox = QSpinBox()
        self.decimalPlacesSpinBox.setRange(0, 6)
        self.decimalPlacesSpinBox.setValue(format_["decimalplaces"])

        decimalPlacesLabel = QLabel("&Decimal places")
        decimalPlacesLabel.setBuddy(self.decimalPlacesSpinBox)

        self.redNegativesCheckBox = QCheckBox("&Red negative numbers")
        self.redNegativesCheckBox.setChecked(format_["rednegatives"])

        self.format = format_
        self.callback = callback

        grid = QGridLayout()
        grid.addWidget(thousandsLabel, 0, 0)
        grid.addWidget(self.thousandsEdit, 0, 1)
        grid.addWidget(decimalMarkerLabel, 1, 0)
        grid.addWidget(self.decimalMarkerEdit, 1, 1)
        grid.addWidget(decimalPlacesLabel, 2, 0)
        grid.addWidget(self.decimalPlacesSpinBox, 2, 1)
        grid.addWidget(self.redNegativesCheckBox, 3, 0, 1, 2)
        self.setLayout(grid)

        self.thousandsEdit.textEdited['QString'].connect(
            self.checkAndFix)
        self.decimalMarkerEdit.textEdited['QString'].connect(
            self.checkAndFix)
        self.decimalPlacesSpinBox.valueChanged[int].connect(
            self.apply)
        self.redNegativesCheckBox.toggled[bool].connect(
            self.apply)
        # self.connect(self.thousandsEdit,
        #         SIGNAL("textEdited(QString)"), self.checkAndFix)
        # self.connect(self.decimalMarkerEdit,
        #         SIGNAL("textEdited(QString)"), self.checkAndFix)
        # self.connect(self.decimalPlacesSpinBox,
        #         SIGNAL("valueChanged(int)"), self.apply)
        # self.connect(self.redNegativesCheckBox,
        #         SIGNAL("toggled(bool)"), self.apply)
        self.setWindowTitle("Set Number Format (`Live')") 
Example 24
Project: PyQt5   Author: andresnino   File: QLineEdit.py    MIT License 4 votes vote down vote up
def initUI(self):

      # =================== WIDGET QLINEEDIT =====================

        self.lineEdit = QLineEdit(self)

        # ================== FUNCIONES PÚBLICAS ==================

        self.lineEdit.setGeometry(20, 20, 360, 24)
        self.lineEdit.setText("Andres Niño")
        # self.lineEdit.setAlignment(Qt.AlignLeft)
        # self.lineEdit.setClearButtonEnabled(True)
        # self.lineEdit.setCursorPosition(6)
        # self.lineEdit.home(True)
        # self.lineEdit.end(True)
        # self.lineEdit.setEchoMode(QLineEdit.Password)
        # self.lineEdit.setFrame(False)
        # self.lineEdit.setMaxLength(2)
        # self.lineEdit.setPlaceholderText("Andres Niño")
        # self.lineEdit.setReadOnly(True)
        # self.lineEdit.setSelection(3, 2)
        # self.lineEdit.selectAll()
        # self.lineEdit.deselect()
        # self.lineEdit.setTextMargins(10, 0, 6, 1)
        # self.lineEdit.setInputMask(">AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;#")
        # self.lineEdit.setValidator(QRegExpValidator(QRegExp("[0-9]+")))
        # print(self.lineEdit.text())

        fuente = QFont()
        fuente.setPointSize(10)
        fuente.setCapitalization(QFont.Capitalize)
        
        self.lineEdit.setFont(fuente)

        # ======================= SEÑALES ========================
        
        # self.lineEdit.returnPressed.connect(lambda: print("Se presiono la tecla Enter..."))
        # self.lineEdit.textChanged.connect(lambda: print("El texto cambio..."))
        # self.lineEdit.textEdited.connect(lambda: print("El texto cambio..."))


# ================================================================ 
Example 25
Project: USBIPManager   Author: lompal   File: ModalAutoFind.py    MIT License 4 votes vote down vote up
def __init__(self, parent=None):
        # noinspection PyArgumentList
        super(FindServerUI, self).__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        uic.loadUi("ui/ModalAutoFind.ui", self)

        # Getting the configuration from config.ini file
        self.config = config.get_config()
        #
        self.from_ip = self.config["SETTINGS"]["find_from_range"]
        self.range_from.setText(self.from_ip)
        self.to_ip = self.config["SETTINGS"]["find_to_range"]
        self.range_to.setText(self.to_ip)

        # Obligatory line edit list
        self.linedit_list = [self.range_from, self.range_to]
        #
        for linedit in self.linedit_list:
            linedit.textChanged.connect(partial(self.text_changed, linedit))

        # Setting IP validation for the search range
        ip_validator = QRegExpValidator(config.ip_regex, self)
        for linedit in self.linedit_list:
            linedit.setValidator(ip_validator)

        # Getting the running event loop
        self.main_loop = get_running_loop()
        # Setting event for interrupting the task running in thread
        self.find_event = Event()

        # Setting buttons clicked actions
        self.find_button.clicked.connect(self.call_auto_find)
        self.stop_button.clicked.connect(self.call_stop_find)
        self.append_button.clicked.connect(self.call_append)
        self.cancel_button.clicked.connect(self.close)

        # Setting right-click context menu to check/uncheck all found servers
        self.search_result.setContextMenuPolicy(Qt.CustomContextMenu)
        self.search_result.customContextMenuRequested.connect(self.search_result_context_menu)

    # ============================================================================ #
    # SYNC FUNCTIONS
    # ============================================================================ #

    #