[PyKDE] 2 Bugs in pyuic for custom widgets

Andreas Pakulat apaku at gmx.de
Wed Jan 25 00:45:49 GMT 2006


Hi,

first I thought you forgot my "fixes" for making custom widgets work.
However you just implemented them in a better way.

Problem is: Both "fixes" don't work anymore :-(

The first one is trivial: I used regexp's for the substitution of "/"
and ".h" for the header-tag. Now you did use plain string functions, but
string.replace doesn't need "/" to be escaped. Thus the
header.replace("\/") actually needs to be header.replace("/").

The 2nd problem seems to be a bigger thing: The findtext method does
_not_ return the default value when it finds an empty element. The
problem is in ElementPath.findtext():

    def findtext(self, element, default=None):
        import logging
	logging.debug("EP: %s, %s" % (element, default))
	logging.debug("EP: %s" % self.tag)
        tag = self.tag
        if tag is None:
	    logging.debug("EP: tag is none")
            nodeset = self.findall(element)
            if not nodeset:
                return default
            return nodeset[0].text or ""
        for elem in element:
	    logging.debug("EP: elem: %s" % elem)
            if elem.tag == tag:
                return elem.text or ""
	logging.debug("EP: Returning: %s" % default)
        return default

(The logging is inserted by me). As you can see it returns "" if the
element is found, thus you have to manually check wether the value
returned by findtext is not "".

Now I don't know wether you want to patch ElementPath (I guess not as
it's probably just copied from ElementTree) or provide another function
for customWidget that replaces "" with "QWidget" for the baseclass. I'm
doing the latter for my uic here until a fix is provided with PyQt4.

Andreas

-- 
Long life is in store for you.




More information about the PyQt mailing list