[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyKDE] custom QValidator
From:       "Adam Tenderholt" <atenderholt () gmail ! com>
Date:       2006-11-22 20:33:45
Message-ID: 7781a1b50611221233j3f735912n9b6603eee92e7b () mail ! gmail ! com
[Download RAW message or body]

I'm trying to create a custom validator, but I'm not having any luck.
The class is reproduced below. When the custom validator is
initialized, it prints the debug message. However,the validate
function is never called. Any ideas?

This is PyQt-4.1 with Qt-4.2.1 (Mac/opensource), sip-4.5, and python 2.4.3.

Thanks,

Adam

------
class ElementValidator(QtGui.QValidator):
    def __init__(self, parent = None):
        QtGui.QValidator.__init__(self, parent)
        self.regexp = QtCore.QRegExp("[A-Z]")
        print "validator created"

    def validate(self, inputStr, pos):
        print "validating"
        if len(inputStr) > 2:
            return (QtGui.QValidator.Invalid,pos)

        if not self.regexp.exactMatch(inputStr[0]):
            return (QtGui.QValidator.Invalid,pos)

        try:
            table.element.index(inputStr)
        except ValueError:
            return (QtGui.QValidator.Intermediate,pos)
        else:
            return (QtGui.QValidator.Acceptable,pos)

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic