[PyKDE] 2 Bugs in pyuic for custom widgets
shlomme at gmx.net
Fri Jan 27 11:23:38 GMT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Andreas Pakulat schrieb:
> 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.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.
thanks for the report - bugs will be fixed in the next snapshots. I would have
tested my changes, but unfortunately I did not have any test harness, was to
lazy to create some myself and trusted in my programming abilities too much
(although my little good programming angel cried out in horror). Could you maybe
send me one of your ui files having such a custom widget?
Torsten Marek <shlomme at gmx.net>
ID: A244C858 -- FP: 1902 0002 5DFC 856B F146 894C 7CC5 451E A244 C858
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the PyQt