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


Python QLineEdit.setValidator方法代碼示例

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


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

示例1: __addSinglesLine

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setValidator [as 別名]
 def __addSinglesLine(self):
     """
     Private slot to add a line of entry widgets for single characters.
     """
     hbox = QWidget(self.singlesItemsBox)
     hboxLayout = QHBoxLayout(hbox)
     hboxLayout.setContentsMargins(0, 0, 0, 0)
     hboxLayout.setSpacing(6)
     hbox.setLayout(hboxLayout)
     cb1 = QComboBox(hbox)
     cb1.setEditable(False)
     cb1.addItems(self.comboItems)
     cb1.addItems(self.singleComboItems)
     hboxLayout.addWidget(cb1)
     le1 = QLineEdit(hbox)
     le1.setValidator(self.charValidator)
     hboxLayout.addWidget(le1)
     cb2 = QComboBox(hbox)
     cb2.setEditable(False)
     cb2.addItems(self.comboItems)
     cb2.addItems(self.singleComboItems)
     hboxLayout.addWidget(cb2)
     le2 = QLineEdit(hbox)
     le2.setValidator(self.charValidator)
     hboxLayout.addWidget(le2)
     self.singlesItemsBoxLayout.addWidget(hbox)
     
     cb1.activated[int].connect(self.__singlesCharTypeSelected)
     cb2.activated[int].connect(self.__singlesCharTypeSelected)
     hbox.show()
     
     self.singlesItemsBox.adjustSize()
     
     self.singlesEntries.append([cb1, le1])
     self.singlesEntries.append([cb2, le2])
開發者ID:pycom,項目名稱:EricShort,代碼行數:37,代碼來源:PyRegExpWizardCharactersDialog.py

示例2: __init__

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setValidator [as 別名]
	def __init__(self, parent=None):
		super(lineEditDemo, self).__init__(parent)
		e1 = QLineEdit()
		e1.setValidator( QIntValidator() )
		e1.setMaxLength(4)
		e1.setAlignment( Qt.AlignRight )
		e1.setFont( QFont("Arial",20))
		e2 = QLineEdit()
		e2.setValidator( QDoubleValidator(0.99,99.99,2))
		flo = QFormLayout()
		flo.addRow("integer validator", e1)
		flo.addRow("Double validator",e2)
		e3 = QLineEdit()
		e3.setInputMask('+99_9999_999999')
		flo.addRow("Input Mask",e3)
		e4 = QLineEdit()
		e4.textChanged.connect( self.textchanged )
		flo.addRow("Text changed",e4)
		e5 = QLineEdit()
		e5.setEchoMode( QLineEdit.Password )
		flo.addRow("Password",e5)
		e6 = QLineEdit("Hello PyQt5")
		e6.setReadOnly(True)
		flo.addRow("Read Only",e6 )
		e5.editingFinished.connect( self.enterPress )
		self.setLayout(flo)
		self.setWindowTitle("QLineEdit例子")
開發者ID:kiorry,項目名稱:PYQT,代碼行數:29,代碼來源:qt04_lineEdit04.py

示例3: addStatControl

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setValidator [as 別名]
 def addStatControl(self,i,label=None):
     statbox = QHBoxLayout()
     statbox.addSpacing(1)
     statbox.setSpacing(0)
     statbox.setAlignment(Qt.AlignCenter)
     statlabel = QLabel(self.stats[i] if label is None else label)
     statlabel.setContentsMargins(0,0,0,0)
     statlabel.setAlignment(Qt.AlignCenter)
     statlabel.setFixedWidth(20)
     statbox.addWidget(statlabel)
     statcontrol = QLineEdit()
     statcontrol.setAlignment(Qt.AlignCenter)
     statcontrol.setFixedWidth(40)
     statcontrol.setText(str(self.skill.multipliers[i]))
     v = QDoubleValidator(0,99,3,statcontrol)
     v.setNotation(QDoubleValidator.StandardNotation)
     #v.setRange(0,100,decimals=3)
     statcontrol.setValidator(v)
     #print(v.top())
     def statFuncMaker(j):
         def statFunc(newValue):
             self.skill.multipliers[j] = float(newValue)
             self.skillsChanged.emit()
         return statFunc
     statcontrol.textChanged[str].connect(statFuncMaker(i))
     statbox.addWidget(statcontrol)
     statbox.addSpacing(1)
     self.layout.addLayout(statbox)
開發者ID:sparsile,項目名稱:padulator,代碼行數:30,代碼來源:padulator.py

示例4: __addRangesLine

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setValidator [as 別名]
 def __addRangesLine(self):
     """
     Private slot to add a line of entry widgets for character ranges.
     """
     hbox = QWidget(self.rangesItemsBox)
     hboxLayout = QHBoxLayout(hbox)
     hboxLayout.setContentsMargins(0, 0, 0, 0)
     hboxLayout.setSpacing(6)
     hbox.setLayout(hboxLayout)
     cb1 = QComboBox(hbox)
     cb1.setEditable(False)
     cb1.addItems(self.comboItems)
     hboxLayout.addWidget(cb1)
     l1 = QLabel(self.tr("Between:"), hbox)
     hboxLayout.addWidget(l1)
     le1 = QLineEdit(hbox)
     le1.setValidator(self.charValidator)
     hboxLayout.addWidget(le1)
     l2 = QLabel(self.tr("And:"), hbox)
     hboxLayout.addWidget(l2)
     le2 = QLineEdit(hbox)
     le2.setValidator(self.charValidator)
     hboxLayout.addWidget(le2)
     self.rangesItemsBoxLayout.addWidget(hbox)
     
     cb1.activated[int].connect(self.__rangesCharTypeSelected)
     
     hbox.show()
     
     self.rangesItemsBox.adjustSize()
     
     self.rangesEntries.append([cb1, le1, le2])
開發者ID:pycom,項目名稱:EricShort,代碼行數:34,代碼來源:PyRegExpWizardCharactersDialog.py

示例5: createEditor

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setValidator [as 別名]
    def createEditor(self, parent, option, index):
        editor = QLineEdit(parent)
        if self.max_length > 0:
            editor.setMaxLength(self.max_length)
        if self.validator is not None:
            editor.setValidator(self.validator)
        editor.setFrame(False)

        return editor
開發者ID:chippey,項目名稱:linux-show-player,代碼行數:11,代碼來源:qdelegates.py

示例6: CueGeneral

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setValidator [as 別名]
class CueGeneral(SettingsSection):

    Name = 'Cue'

    def __init__(self, size, cue=None, parent=None):
        super().__init__(size, cue=cue, parent=parent)

        self.setLayout(QVBoxLayout(self))

        # Groups
        self.groupGroups = QGroupBox(self)
        self.groupGroups.setTitle("Edit groups")
        self.horizontalLayout_5 = QHBoxLayout(self.groupGroups)

        self.editGroups = QLineEdit(self.groupGroups)
        regex = QtCore.QRegExp('(\d+,)*')
        self.editGroups.setValidator(QRegExpValidator(regex))
        sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
        self.editGroups.setSizePolicy(sizePolicy)
        self.horizontalLayout_5.addWidget(self.editGroups)

        self.groupsEditLabel = QLabel(self.groupGroups)
        self.groupsEditLabel.setText("Modify groups [0,1,2,...,n]")
        self.groupsEditLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.horizontalLayout_5.addWidget(self.groupsEditLabel)

        self.layout().addWidget(self.groupGroups)

    def get_configuration(self):
        conf = {}

        checkable = self.groupGroups.isCheckable()

        if(not (checkable and not self.groupGroups.isChecked())):
            groups_str = self.editGroups.text().split(',')
            if(groups_str[-1] != ''):
                conf['groups'] = [int(groups_str[-1])]
            else:
                conf['groups'] = []
            conf['groups'] += [int(g) for g in groups_str[:-1]]

        return conf

    def enable_check(self, enable):
        self.groupGroups.setCheckable(enable)
        self.groupGroups.setChecked(False)

    def set_configuration(self, conf):
        if('groups' in conf):
            self.editGroups.setText(str(conf['groups'])[1:-1])
開發者ID:tornel,項目名稱:linux-show-player,代碼行數:52,代碼來源:cue_general.py

示例7: create_LineEdit

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setValidator [as 別名]
def create_LineEdit(maxsize, validator, maxlength):
    """Create a lineEdit with the given attributes.

    Keyword arguments:
    maxsize -- maximum size
    validator -- a QValidator
    maxlength - maximum length

    Returns: QLineEdit
    """
    lineEdit = QLineEdit()
    if maxsize is not None:
        lineEdit.setMaximumSize(QSize(maxsize[0], maxsize[1]))
    if validator is not None:
        lineEdit.setValidator(validator)
    if maxlength is not None:
        lineEdit.setMaxLength(maxlength)
    return lineEdit
開發者ID:Ilias95,項目名稱:FF-Multi-Converter,代碼行數:20,代碼來源:utils.py

示例8: DocumentationGroupBox

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setValidator [as 別名]
class DocumentationGroupBox(QGroupBox):
    def __init__(self, enabled=False, max_deduction=0, deduction=0):            
        def onMaxEditPoint(new_max):
            self.max_deduction = int(new_max)

        def onEditPoint(new_deduction):
            if int(new_deduction) > self.max_deduction:
                error = QMessageBox(QMessageBox.Critical, 'Error',"The point deduction per element missing can't be greater than the maximum point deduction", QMessageBox.Ok, self)
                error.show()
            else:
                self.deduction_per_elem = int(new_deduction)

        super().__init__()
        self.max_deduction = max_deduction;
        self.deduction_per_elem = deduction

        point_validator = QIntValidator()
        
        point_label = QLabel('Points deduction per element missing:')
        self.point_edit = QLineEdit()
        self.point_edit.setMaximumWidth(50)
        self.point_edit.setText('0')
        self.point_edit.setValidator(point_validator)
        self.point_edit.textChanged.connect(lambda new_deduction: onEditPoint(new_deduction))

        max_point_label = QLabel('Maximum points deduction:')
        self.max_point_edit = QLineEdit()
        self.max_point_edit.setMaximumWidth(50)
        self.max_point_edit.setText('0')
        self.max_point_edit.setValidator(point_validator)
        self.max_point_edit.textChanged.connect(lambda new_max: onMaxEditPoint(new_max))

        gb_grid = QGridLayout()

        gb_grid.addWidget(point_label, 0, 0, 1, 1)
        gb_grid.addWidget(self.point_edit, 0, 1, 1, 1)
        gb_grid.addWidget(max_point_label, 1, 0, 1, 1)
        gb_grid.addWidget(self.max_point_edit, 1, 1, 1, 1)

        self.setLayout(gb_grid)
        self.setTitle('Documentation')
        self.setCheckable(True)
        self.setChecked(enabled)
開發者ID:faouellet,項目名稱:CorrectUS,代碼行數:45,代碼來源:documentationgb.py

示例9: GotoLineDialog

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setValidator [as 別名]
class GotoLineDialog(QDialog):
    """
    A QDialog_ that asks for a line:column number to the user. Column number is
    optional.

    The result may be passed to the :func:`scrollToLine` function of
    :class:`BaseCodeEditor`.

    .. _QDialog: http://doc.qt.io/qt-5/qdialog.html
    """

    def __init__(self, parent=None):
        super(GotoLineDialog, self).__init__(parent)
        self.setWindowModality(Qt.WindowModal)
        self.setWindowTitle(self.tr("Go to…"))

        self.lineEdit = QLineEdit(self)
        validator = QRegularExpressionValidator(self)
        validator.setRegularExpression(
            QRegularExpression("(^[1-9][0-9]*(:[1-9][0-9]*)?$)?"))
        self.lineEdit.setValidator(validator)
        self.lineEdit.returnPressed.connect(self.accept)
        label = QLabel(self.tr("Enter a row:column to go to"), self)

        layout = QVBoxLayout(self)
        layout.addWidget(self.lineEdit)
        layout.addWidget(label)
        self.setLayout(layout)

    @classmethod
    def getLineColumnNumber(cls, parent):
        dialog = cls(parent)
        result = dialog.exec_()
        newLine = dialog.lineEdit.text()
        if newLine:
            newLine = [int(nb) for nb in newLine.split(":")]
        else:
            newLine = [None]
        if len(newLine) < 2:
            newLine.append(None)
        newLine.append(result)
        return tuple(newLine)
開發者ID:adrientetar,項目名稱:defconQt,代碼行數:44,代碼來源:baseCodeEditor.py

示例10: createEditor

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setValidator [as 別名]
    def createEditor(self, parent, option, index):
        if index.column() != 2:
            return None

        originalValue = index.model().data(index, Qt.UserRole)
        if not self.isSupportedType(originalValue):
            return None

        lineEdit = QLineEdit(parent)
        lineEdit.setFrame(False)

        if isinstance(originalValue, bool):
            regExp = self.boolExp
        elif isinstance(originalValue, float):
            regExp = self.doubleExp
        elif isinstance(originalValue, int):
            regExp = self.signedIntegerExp
        elif isinstance(originalValue, QByteArray):
            regExp = self.byteArrayExp
        elif isinstance(originalValue, QColor):
            regExp = self.colorExp
        elif isinstance(originalValue, QDate):
            regExp = self.dateExp
        elif isinstance(originalValue, QDateTime):
            regExp = self.dateTimeExp
        elif isinstance(originalValue, QTime):
            regExp = self.timeExp
        elif isinstance(originalValue, QPoint):
            regExp = self.pointExp
        elif isinstance(originalValue, QRect):
            regExp = self.rectExp
        elif isinstance(originalValue, QSize):
            regExp = self.sizeExp
        else:
            regExp = QRegExp()

        if not regExp.isEmpty():
            validator = QRegExpValidator(regExp, lineEdit)
            lineEdit.setValidator(validator)

        return lineEdit
開發者ID:Axel-Erfurt,項目名稱:pyqt5,代碼行數:43,代碼來源:settingseditor.py

示例11: __init__

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setValidator [as 別名]
	def __init__(self, parent=None):
		super(lineEditDemo, self).__init__(parent)
		self.setWindowTitle("QLineEdit例子")

		flo = QFormLayout()
		pIntLineEdit  = QLineEdit( )
		pDoubleLineEdit  = QLineEdit()
		pValidatorLineEdit  = QLineEdit( )

		flo.addRow("整形", pIntLineEdit)
		flo.addRow("浮點型", pDoubleLineEdit)
		flo.addRow("字母和數字", pValidatorLineEdit)
        
		pIntLineEdit.setPlaceholderText("整形");
		pDoubleLineEdit.setPlaceholderText("浮點型");
		pValidatorLineEdit.setPlaceholderText("字母和數字");

		# 整形 範圍:[1, 99]
		pIntValidator = QIntValidator(self)
		pIntValidator.setRange(1, 99)

		# 浮點型 範圍:[-360, 360] 精度:小數點後2位
		pDoubleValidator = QDoubleValidator(self)
		pDoubleValidator.setRange(-360, 360)
		pDoubleValidator.setNotation(QDoubleValidator.StandardNotation)
		pDoubleValidator.setDecimals(2)
		
		# 字符和數字
		reg = QRegExp("[a-zA-Z0-9]+$")
		pValidator = QRegExpValidator(self)
		pValidator.setRegExp(reg)	

        # 設置驗證器
		pIntLineEdit.setValidator(pIntValidator)
		pDoubleLineEdit.setValidator(pDoubleValidator)
		pValidatorLineEdit.setValidator(pValidator)
		                    
		self.setLayout(flo)                        
開發者ID:kiorry,項目名稱:PYQT,代碼行數:40,代碼來源:qt04_lineEdit02.py

示例12: Client

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setValidator [as 別名]
class Client(QDialog):
    def __init__(self, parent=None):
        super(Client, self).__init__(parent)

        self.networkSession = None
        self.blockSize = 0
        self.currentFortune = ""

        hostLabel = QLabel("&Server name:")
        portLabel = QLabel("S&erver port:")

        self.hostCombo = QComboBox()
        self.hostCombo.setEditable(True)

        name = QHostInfo.localHostName()
        if name != "":
            self.hostCombo.addItem(name)

            domain = QHostInfo.localDomainName()
            if domain != "":
                self.hostCombo.addItem(name + "." + domain)

        if name != "localhost":
            self.hostCombo.addItem("localhost")

        ipAddressesList = QNetworkInterface.allAddresses()

        for ipAddress in ipAddressesList:
            if not ipAddress.isLoopback():
                self.hostCombo.addItem(ipAddress.toString())

        for ipAddress in ipAddressesList:
            if ipAddress.isLoopback():
                self.hostCombo.addItem(ipAddress.toString())

        self.portLineEdit = QLineEdit()
        self.portLineEdit.setValidator(QIntValidator(1, 65535, self))

        hostLabel.setBuddy(self.hostCombo)
        portLabel.setBuddy(self.portLineEdit)

        self.statusLabel = QLabel("This examples requires that you run " "the Fortune Server example as well.")

        self.getFortuneButton = QPushButton("Get Fortune")
        self.getFortuneButton.setDefault(True)
        self.getFortuneButton.setEnabled(False)

        quitButton = QPushButton("Quit")

        buttonBox = QDialogButtonBox()
        buttonBox.addButton(self.getFortuneButton, QDialogButtonBox.ActionRole)
        buttonBox.addButton(quitButton, QDialogButtonBox.RejectRole)

        self.tcpSocket = QTcpSocket(self)

        self.hostCombo.editTextChanged.connect(self.enableGetFortuneButton)
        self.portLineEdit.textChanged.connect(self.enableGetFortuneButton)
        self.getFortuneButton.clicked.connect(self.requestNewFortune)
        quitButton.clicked.connect(self.close)
        self.tcpSocket.readyRead.connect(self.readFortune)
        self.tcpSocket.error.connect(self.displayError)

        mainLayout = QGridLayout()
        mainLayout.addWidget(hostLabel, 0, 0)
        mainLayout.addWidget(self.hostCombo, 0, 1)
        mainLayout.addWidget(portLabel, 1, 0)
        mainLayout.addWidget(self.portLineEdit, 1, 1)
        mainLayout.addWidget(self.statusLabel, 2, 0, 1, 2)
        mainLayout.addWidget(buttonBox, 3, 0, 1, 2)
        self.setLayout(mainLayout)

        self.setWindowTitle("Fortune Client")
        self.portLineEdit.setFocus()

        manager = QNetworkConfigurationManager()
        if manager.capabilities() & QNetworkConfigurationManager.NetworkSessionRequired:
            settings = QSettings(QSettings.UserScope, "QtProject")
            settings.beginGroup("QtNetwork")
            id = settings.value("DefaultNetworkConfiguration")
            settings.endGroup()

            config = manager.configurationFromIdentifier(id)
            if config.state() & QNetworkConfiguration.Discovered == 0:
                config = manager.defaultConfiguration()

            self.networkSession = QNetworkSession(config, self)
            self.networkSession.opened.connect(self.sessionOpened)

            self.getFortuneButton.setEnabled(False)
            self.statusLabel.setText("Opening network session.")
            self.networkSession.open()

    def requestNewFortune(self):
        self.getFortuneButton.setEnabled(False)
        self.blockSize = 0
        self.tcpSocket.abort()
        self.tcpSocket.connectToHost(self.hostCombo.currentText(), int(self.portLineEdit.text()))

    def readFortune(self):
        instr = QDataStream(self.tcpSocket)
#.........這裏部分代碼省略.........
開發者ID:death-finger,項目名稱:Scripts,代碼行數:103,代碼來源:fortuneclient.py

示例13: IncludeGroupBox

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setValidator [as 別名]
class IncludeGroupBox(QGroupBox):
    def __init__(self, enabled=False, max_deduction=0, deduction=0, check_superfluous=False, check_order=False):         
        def onMaxEditPoint(line_edit):
            self.max_deduction = int(line_edit.text())

        def onEditPoint(line_edit, max_deduction):
            point_deduction = int(line_edit.text())
            if point_deduction > max_deduction:
                error = QMessageBox(QMessageBox.Critical, 'Error',"The point deduction per error missing can't be greater than the maximum point deduction", QMessageBox.Ok, self)
                error.show()
            else:
                self.deduction_per_elem = point_deduction

        def onCheckMin(state):
            self.check_superfluous = False if state == Qt.Unchecked else True

        def onCheckOrder(state, check):
            self.check_order = False if state == Qt.Unchecked else True
            
        super().__init__()
        self.max_deduction = max_deduction;
        self.deduction_per_elem = deduction
        self.check_superfluous = check_superfluous
        self.check_order = check_order

        point_validator = QIntValidator()
        
        point_label = QLabel('Points deduction per error:')
        self.point_edit = QLineEdit()
        self.point_edit.setMaximumWidth(50)
        self.point_edit.setText('0')
        self.point_edit.setValidator(point_validator)
        self.point_edit.editingFinished.connect(lambda: onEditPoint(self.point_edit, self.max_deduction))

        max_point_label = QLabel('Maximum points deduction:')
        self.max_point_edit = QLineEdit()
        self.max_point_edit.setMaximumWidth(50)
        self.max_point_edit.setText('0')
        self.max_point_edit.setValidator(point_validator)
        self.max_point_edit.editingFinished.connect(lambda: onMaxEditPoint(self.max_point_edit))

        min_include_label = QLabel('Check for superfluous includes')
        self.min_include_chkbox = QCheckBox()
        self.min_include_chkbox.stateChanged.connect(lambda state: onCheckMin(state))

        order_include_label = QLabel('Check includes order')
        self.order_include_chkbox = QCheckBox()
        self.order_include_chkbox.stateChanged.connect(lambda state: onCheckOrder(state))

        gb_grid = QGridLayout()

        gb_grid.addWidget(min_include_label, 0, 0, 1, 1)
        gb_grid.addWidget(self.min_include_chkbox, 0, 1, 1, 1)
        gb_grid.addWidget(order_include_label, 1, 0, 1, 1)
        gb_grid.addWidget(self.order_include_chkbox, 1, 1, 1, 1)

        gb_grid.addWidget(point_label, 2, 0, 1, 1)
        gb_grid.addWidget(self.point_edit, 2, 1, 1, 1)
        gb_grid.addWidget(max_point_label, 3, 0, 1, 1)
        gb_grid.addWidget(self.max_point_edit, 3, 1, 1, 1)

        self.setLayout(gb_grid)
        self.setTitle('Includes')
        self.setCheckable(True)
        self.setChecked(enabled)
開發者ID:faouellet,項目名稱:CorrectUS,代碼行數:67,代碼來源:includegb.py

示例14: BlockingClient

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setValidator [as 別名]
class BlockingClient(QWidget):
    def __init__(self, parent=None):
        super(BlockingClient, self).__init__(parent)

        self.thread = FortuneThread()
        self.currentFortune = ''

        hostLabel = QLabel("&Server name:")
        portLabel = QLabel("S&erver port:")

        for ipAddress in QNetworkInterface.allAddresses():
            if ipAddress != QHostAddress.LocalHost and ipAddress.toIPv4Address() != 0:
                break
        else:
            ipAddress = QHostAddress(QHostAddress.LocalHost)

        ipAddress = ipAddress.toString()

        self.hostLineEdit = QLineEdit(ipAddress)
        self.portLineEdit = QLineEdit()
        self.portLineEdit.setValidator(QIntValidator(1, 65535, self))

        hostLabel.setBuddy(self.hostLineEdit)
        portLabel.setBuddy(self.portLineEdit)

        self.statusLabel = QLabel(
                "This example requires that you run the Fortune Server example as well.")
        self.statusLabel.setWordWrap(True)

        self.getFortuneButton = QPushButton("Get Fortune")
        self.getFortuneButton.setDefault(True)
        self.getFortuneButton.setEnabled(False)

        quitButton = QPushButton("Quit")

        buttonBox = QDialogButtonBox()
        buttonBox.addButton(self.getFortuneButton, QDialogButtonBox.ActionRole)
        buttonBox.addButton(quitButton, QDialogButtonBox.RejectRole)

        self.getFortuneButton.clicked.connect(self.requestNewFortune)
        quitButton.clicked.connect(self.close)
        self.hostLineEdit.textChanged.connect(self.enableGetFortuneButton)
        self.portLineEdit.textChanged.connect(self.enableGetFortuneButton)
        self.thread.newFortune.connect(self.showFortune)
        self.thread.error.connect(self.displayError)

        mainLayout = QGridLayout()
        mainLayout.addWidget(hostLabel, 0, 0)
        mainLayout.addWidget(self.hostLineEdit, 0, 1)
        mainLayout.addWidget(portLabel, 1, 0)
        mainLayout.addWidget(self.portLineEdit, 1, 1)
        mainLayout.addWidget(self.statusLabel, 2, 0, 1, 2)
        mainLayout.addWidget(buttonBox, 3, 0, 1, 2)
        self.setLayout(mainLayout)

        self.setWindowTitle("Blocking Fortune Client")
        self.portLineEdit.setFocus()

    def requestNewFortune(self):
        self.getFortuneButton.setEnabled(False)
        self.thread.requestNewFortune(self.hostLineEdit.text(),
                int(self.portLineEdit.text()))

    def showFortune(self, nextFortune):
        if nextFortune == self.currentFortune:
            self.requestNewFortune()
            return

        self.currentFortune = nextFortune
        self.statusLabel.setText(self.currentFortune)
        self.getFortuneButton.setEnabled(True)

    def displayError(self, socketError, message):
        if socketError == QAbstractSocket.HostNotFoundError:
            QMessageBox.information(self, "Blocking Fortune Client",
                    "The host was not found. Please check the host and port "
                    "settings.")
        elif socketError == QAbstractSocket.ConnectionRefusedError:
            QMessageBox.information(self, "Blocking Fortune Client",
                    "The connection was refused by the peer. Make sure the "
                    "fortune server is running, and check that the host name "
                    "and port settings are correct.")
        else:
            QMessageBox.information(self, "Blocking Fortune Client",
                    "The following error occurred: %s." % message)

        self.getFortuneButton.setEnabled(True)

    def enableGetFortuneButton(self):
        self.getFortuneButton.setEnabled(self.hostLineEdit.text() != '' and
                self.portLineEdit.text() != '')
開發者ID:Axel-Erfurt,項目名稱:pyqt5,代碼行數:93,代碼來源:blockingfortuneclient.py

示例15: PostScriptTab

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setValidator [as 別名]
class PostScriptTab(QWidget):
    name = "Postscript"

    def __init__(self, font, parent=None):
        super(PostScriptTab, self).__init__(parent)

        namingGroup = QGroupBox("Naming", self)
        # namingGroup.setFlat(True)
        namingLayout = QGridLayout(self)

        fontNameLabel = QLabel("FontName:", self)
        self.fontNameEdit = QLineEdit(font.info.postscriptFontName, self)

        fullNameLabel = QLabel("FullName:", self)
        self.fullNameEdit = QLineEdit(font.info.postscriptFullName, self)

        weightNameLabel = QLabel("WeightName:", self)
        self.weightNameEdit = QLineEdit(font.info.postscriptWeightName, self)

        uniqueIDLabel = QLabel("Unique ID:", self)
        if font.info.postscriptUniqueID is not None:
            uniqueID = str(font.info.postscriptUniqueID)
        else:
            uniqueID = ''
        self.uniqueIDEdit = QLineEdit(uniqueID, self)
        self.uniqueIDEdit.setValidator(QIntValidator(self))

        l = 0
        namingLayout.addWidget(fontNameLabel, l, 0)
        namingLayout.addWidget(self.fontNameEdit, l, 1, 1, 2)
        namingLayout.addWidget(weightNameLabel, l, 3)
        namingLayout.addWidget(self.weightNameEdit, l, 4, 1, 2)
        l += 1
        namingLayout.addWidget(fullNameLabel, l, 0)
        namingLayout.addWidget(self.fullNameEdit, l, 1, 1, 2)
        namingLayout.addWidget(uniqueIDLabel, l, 3)
        namingLayout.addWidget(self.uniqueIDEdit, l, 4, 1, 2)
        namingGroup.setLayout(namingLayout)

        hintingGroup = QGroupBox("Hinting", self)
        # hintingGroup.setFlat(True)
        hintingLayout = QGridLayout(self)

        blueValuesLabel = QLabel("Blue values:", self)
        blueValues = " ".join(str(val)
                              for val in font.info.postscriptBlueValues)
        self.blueValuesEdit = QLineEdit(blueValues, self)

        otherBluesLabel = QLabel("Other blues:", self)
        otherBlues = " ".join(str(val)
                              for val in font.info.postscriptOtherBlues)
        self.otherBluesEdit = QLineEdit(otherBlues, self)

        familyBluesLabel = QLabel("Family blues:", self)
        familyBlues = " ".join(str(val)
                               for val in font.info.postscriptFamilyBlues)
        self.familyBluesEdit = QLineEdit(familyBlues, self)

        familyOtherBluesLabel = QLabel("Family other blues:", self)
        familyOtherBlues = " ".join(
            str(val) for val in font.info.postscriptFamilyOtherBlues)
        self.familyOtherBluesEdit = QLineEdit(familyOtherBlues, self)

        l = 0
        hintingLayout.addWidget(blueValuesLabel, l, 0)
        hintingLayout.addWidget(self.blueValuesEdit, l, 1, 1, 2)
        hintingLayout.addWidget(familyBluesLabel, l, 3)
        hintingLayout.addWidget(self.familyBluesEdit, l, 4, 1, 2)
        l += 1
        hintingLayout.addWidget(otherBluesLabel, l, 0)
        hintingLayout.addWidget(self.otherBluesEdit, l, 1, 1, 2)
        hintingLayout.addWidget(familyOtherBluesLabel, l, 3)
        hintingLayout.addWidget(self.familyOtherBluesEdit, l, 4, 1, 2)
        l += 1

        blueFuzzLabel = QLabel("Blue fuzz:", self)
        if font.info.postscriptBlueFuzz is not None:
            blueFuzz = str(font.info.postscriptBlueFuzz)
        else:
            blueFuzz = ''
        self.blueFuzzEdit = QLineEdit(blueFuzz, self)
        self.blueFuzzEdit.setValidator(QDoubleValidator(self))

        stemSnapHLabel = QLabel("StemSnapH:", self)
        stemSnapH = " ".join(str(val) for val in font.info.postscriptStemSnapH)
        self.stemSnapHEdit = QLineEdit(stemSnapH, self)

        blueScaleLabel = QLabel("Blue scale:", self)
        if font.info.postscriptBlueScale is not None:
            blueScale = str(font.info.postscriptBlueScale)
        else:
            blueScale = ''
        self.blueScaleEdit = QLineEdit(blueScale, self)
        self.blueScaleEdit.setValidator(QDoubleValidator(self))

        stemSnapVLabel = QLabel("StemSnapV:", self)
        stemSnapV = " ".join(str(val) for val in font.info.postscriptStemSnapV)
        self.stemSnapVEdit = QLineEdit(stemSnapV, self)

        blueShiftLabel = QLabel("Blue shift:", self)
#.........這裏部分代碼省略.........
開發者ID:n7s,項目名稱:trufont,代碼行數:103,代碼來源:fontInfo.py


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