當前位置: 首頁>>代碼示例>>Python>>正文


Python QtGui.QRegExpValidator方法代碼示例

本文整理匯總了Python中PyQt4.QtGui.QRegExpValidator方法的典型用法代碼示例。如果您正苦於以下問題:Python QtGui.QRegExpValidator方法的具體用法?Python QtGui.QRegExpValidator怎麽用?Python QtGui.QRegExpValidator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt4.QtGui的用法示例。


在下文中一共展示了QtGui.QRegExpValidator方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: startUi

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QRegExpValidator [as 別名]
def startUi(self):
        """This function checks if ui file exists and then show the view"""
        try:
            self.load("project")

            self.lineEditLocation.setText(expanduser("~"))
            regex = QRegExp("\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}")
            self.__validator = QRegExpValidator(regex, self.lineEditIP)
            self.lineEditIP.setValidator(self.__validator)

            # Connect things
            self.buttonBox.rejected.connect(self.buttonBoxRejected)
            self.buttonBox.accepted.connect(self.buttonBoxAccepted)
            self.toolButton.clicked.connect(self.toolButtonClicked)
            return True
        except Exception as e:
            MessageBox.critical("Error", str(e))
            return False 
開發者ID:danilabs,項目名稱:rexploit,代碼行數:20,代碼來源:projectview.py

示例2: startUi

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QRegExpValidator [as 別名]
def startUi(self):
        """This function checks if ui file exists and then show the view"""
        try:
            self.load("settings")

            regex = QRegExp("\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}")
            self.__validator = QRegExpValidator(regex, self.lineEditIP)
            self.lineEditIP.setValidator(self.__validator)

            # Connect things
            self.buttonBox.rejected.connect(self.buttonBoxRejected)
            self.buttonBox.accepted.connect(self.buttonBoxAccepted)
            self.toolButton.clicked.connect(self.toolButtonClicked)
            self.pushButtonPing.clicked.connect(self.pushButtonPingClicked)
            return True
        except Exception as e:
            MessageBox.critical("Error", str(e))
            return False 
開發者ID:danilabs,項目名稱:rexploit,代碼行數:20,代碼來源:settingsview.py

示例3: __init__

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QRegExpValidator [as 別名]
def __init__(self, parent):
        super(BruteForceView, self).__init__("bruteforce", parent)
        self.category = "bf"

        regex = QRegExp("\d{1,6}")
        self.__validator = QRegExpValidator(regex, self.lineEditPort)
        self.lineEditPort.setValidator(self.__validator)

        regex = QRegExp("\d{1,5}")

        self.__validator = QRegExpValidator(regex, self.lineEditPort)
        self.lineEditMaximum.setValidator(self.__validator)

        # Connect buttons
        self.pushButtonCancel.clicked.connect(self.pushButtonCancelClicked)
        self.pushButtonExploit.clicked.connect(self.pushButtonExploitClicked)
        self.toolButtonUsers.clicked.connect(self.toolButtonUsersClicked)
        self.toolButtonPasswords.clicked.connect(self.toolButtonPasswordsClicked)

        # Connect signal and thread
        self.__communicate = Communicate()
        self.__exploitThread = ExploitThread(self.__communicate)
        self.__communicate.finishExploit.connect(self.setResultExploit)

        # Button and progressbar
        self.setProgressBarState(0)
        self.pushButtonCancel.setEnabled(False)

        # Generator
        self.__generatorUsers = Generator()
        self.__generatorPasswords = Generator() 
開發者ID:danilabs,項目名稱:rexploit,代碼行數:33,代碼來源:bruteforceview.py

示例4: __init__

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QRegExpValidator [as 別名]
def __init__(self, parent=None):
		super(SmartInfoDialog, self).__init__(parent)

		# Weak email validation regex: http://www.regular-expressions.info/email.html
		self._email_rx = QtCore.QRegExp(
			r'^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$', 
			QtCore.Qt.CaseInsensitive)

		self.email.setValidator(QtGui.QRegExpValidator(self._email_rx )) 
開發者ID:justinfx,項目名稱:tutorials,代碼行數:11,代碼來源:dialog_validation.py

示例5: validate_text

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QRegExpValidator [as 別名]
def validate_text(self, text):
        """
        Validates and updates the entered text if necessary.
        :param text: The text entered
        :type text: String
        """
        text_edit = self.sender()

        cursor_position = text_edit.cursorPosition()
        text_edit.setValidator(None)
        if len(text) == 0:
            return
        locale = QSettings().value("locale/userLocale")[0:2]

        if locale == 'en':
            name_regex = QtCore.QRegExp('^[ _0-9a-zA-Z][a-zA-Z0-9_/\\-()|.:,; ]*$')
            name_validator = QtGui.QRegExpValidator(name_regex)
            text_edit.setValidator(name_validator)
            QApplication.processEvents()
            last_character = text[-1:]
            state = name_validator.validate(text, text.index(last_character))[0]
            if state != QValidator.Acceptable:
                self.show_notification(u'"{}" is not allowed at this position.'.
                                       format(last_character)
                                       )
                text = text[:-1]

        if len(text) > 1:
            if text[0] == ' ' or text[0] == '_':
                text = text[1:]

        self.blockSignals(True)
        text_edit.setText(text)
        text_edit.setCursorPosition(cursor_position)
        self.blockSignals(False)
        text_edit.setValidator(None) 
開發者ID:gltn,項目名稱:stdm,代碼行數:38,代碼來源:create_lookup_value.py

示例6: init_gui

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QRegExpValidator [as 別名]
def init_gui(self):
        """
        Initializes form widgets
        """
        charlen_regex = QtCore.QRegExp('^[0-9]{1,3}$')
        charlen_validator = QtGui.QRegExpValidator(charlen_regex)
        self.edtCharLen.setValidator(charlen_validator)

        self.edtCharLen.setText(str(self._max_len))
        self.edtCharLen.setFocus()

        self.edtCharLen.setEnabled(not self.in_db) 
開發者ID:gltn,項目名稱:stdm,代碼行數:14,代碼來源:varchar_property.py

示例7: hexeditor

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QRegExpValidator [as 別名]
def hexeditor(self):
        self.dialogbox = widgets.QWidget()
        wlayout = widgets.QVBoxLayout()
        diaglabel = widgets.QLabel(_("Diagnostic session"))
        inputlabel = widgets.QLabel(_("Input"))
        outputlabel = widgets.QLabel(_("Output"))

        diaglabel.setAlignment(core.Qt.AlignCenter)
        inputlabel.setAlignment(core.Qt.AlignCenter)
        outputlabel.setAlignment(core.Qt.AlignCenter)

        self.diagsession = widgets.QComboBox()
        rqsts = self.ecurequestsparser.requests.keys()
        self.request_editor_sds = {}

        self.diagsession.addItem(u"None")
        self.request_editor_sds[u'None'] = ""


        for diag in rqsts:
            if "start" in diag.lower() and "session" in diag.lower() and 'diag' in diag.lower():

                sds = self.ecurequestsparser.requests[diag]

                if u'Session Name' in sds.sendbyte_dataitems:
                    session_names = self.ecurequestsparser.data[u'Session Name']
                    for name in session_names.items.keys():
                        sds_stream = " ".join(sds.build_data_stream({u'Session Name': name}))
                        name = name + "[" + sds_stream + "]"
                        self.request_editor_sds[name] = sds_stream
                        self.diagsession.addItem(name)
                    print sds.sendbyte_dataitems[u'Session Name']

        if len(self.request_editor_sds) == 1:
            for k, v in self.sds.iteritems():
                self.diagsession.addItem(k)
                self.request_editor_sds[k] = v

        self.input = widgets.QLineEdit()
        self.input.returnPressed.connect(self.send_manual_cmd)
        self.output = widgets.QLineEdit()
        self.output.setReadOnly(True)
        hexvalidaor = core.QRegExp(("^[\s0-9a-fA-F]+"))
        rev = gui.QRegExpValidator(hexvalidaor, self)
        self.input.setValidator(rev)
        wlayout.addWidget(diaglabel)
        wlayout.addWidget(self.diagsession)
        wlayout.addWidget(inputlabel)
        wlayout.addWidget(self.input)
        wlayout.addWidget(outputlabel)
        wlayout.addWidget(self.output)
        self.dialogbox.setLayout(wlayout)
        self.dialogbox.show() 
開發者ID:cedricp,項目名稱:ddt4all,代碼行數:55,代碼來源:parameters.py

示例8: validate_text

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QRegExpValidator [as 別名]
def validate_text(self, text):
        """
        Validates and updates the entered text if necessary.
        Spaces are replaced by _ and capital letters are replaced by small.
        :param text: The text entered
        :type text: String
        """
        text_edit = self.sender()
        cursor_position = text_edit.cursorPosition()
        text_edit.setValidator(None)
        if len(text) == 0:
            return

        name_regex = QtCore.QRegExp('^(?=.{0,40}$)[ _a-zA-Z][a-zA-Z0-9_ ]*$')
        name_validator = QtGui.QRegExpValidator(name_regex)
        text_edit.setValidator(name_validator)
        QApplication.processEvents()
        last_character = text[-1:]
        locale = QSettings().value("locale/userLocale")[0:2]

        #if locale == 'en':
        state = name_validator.validate(text, text.index(last_character))[0]
        if state != QValidator.Acceptable:
            self.show_notification(u'"{}" is not allowed at this position.'.
                format(last_character)
            )
            text = text[:-1]

        # fix caps, _, and spaces
        if last_character.isupper():
            text = text.lower()
        if last_character == ' ':
            text = text.replace(' ', '_')
        if len(text) > 1:
            if text[0] == ' ' or text[0] == '_':
                text = text[1:]
            text = text.replace(' ', '_').lower()

        self.blockSignals(True)
        text_edit.setText(text)
        text_edit.setCursorPosition(cursor_position)
        self.blockSignals(False)
        text_edit.setValidator(None) 
開發者ID:gltn,項目名稱:stdm,代碼行數:45,代碼來源:column_editor.py

示例9: validate_text

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QRegExpValidator [as 別名]
def validate_text(self, text):
        """
        Validates and updates the entered text if necessary.
        Spaces are replaced by _ and capital letters are replaced by small.
        :param text: The text entered
        :type text: String
        """
        text_edit = self.sender()
        cursor_position = text_edit.cursorPosition()
        text_edit.setValidator(None)
        if len(text) == 0:
            return
        locale = QSettings().value("locale/userLocale")[0:2]
        last_character = text[-1:]
        if locale == 'en':
            name_regex = QtCore.QRegExp('^(?=.{0,40}$)[ _a-zA-Z][a-zA-Z0-9_ ]*$')
            name_validator = QtGui.QRegExpValidator(name_regex)
            text_edit.setValidator(name_validator)
            QApplication.processEvents()

            state = name_validator.validate(text, text.index(last_character))[0]
            if state != QValidator.Acceptable:
                self.show_notification(u'"{}" is not allowed at this position.'.
                                       format(last_character)
                                       )
                text = text[:-1]

        # fix caps, underscores, and spaces
        if last_character.isupper():
            text = text.lower()
        if last_character == ' ':
            text = text.replace(' ', '_')

        if len(text) > 1:
            if text[0] == ' ' or text[0] == '_':
                text = text[1:]
            text = text.replace(' ', '_').lower()

        self.blockSignals(True)
        text_edit.setText(text)
        text_edit.setCursorPosition(cursor_position)
        self.blockSignals(False)
        text_edit.setValidator(None) 
開發者ID:gltn,項目名稱:stdm,代碼行數:45,代碼來源:create_lookup.py


注:本文中的PyQt4.QtGui.QRegExpValidator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。