[PyKDE] TypeError: 'QObjectCreator' object is unsubscriptable

Torsten Marek shlomme at gmx.net
Sat Oct 21 18:16:01 BST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Matt Newell schrieb:
> On Thursday 19 October 2006 08:00, Michael 'Mickey' Lauer wrote:
>> Hi,
>>
>> I'm using Qt4.2 + sip/PyQt snapshots from 20061015:
>> I'm getting the aforementioned error when supplying a baseclass to
>> uic.loadUi. It also occurs on the load_ui2.py demo program.
>>
>> Any idea?
>>
>> Thanks,
> 
> 
> I posted a patch about a week ago to fix this problem.  Attached.
> 
> Matt
> 
> 
> 
> ------------------------------------------------------------------------
> 
> diff -ru PyQt-win-gpl-4-snapshot-20060930/pyuic/uic/Loader/loader.py pyuic/uic/Loader/loader.py
> --- PyQt-win-gpl-4-snapshot-20060930/pyuic/uic/Loader/loader.py 2006-10-11 10:06:22.000000000 -0700
> +++ pyuic/uic/Loader/loader.py  2006-10-11 10:06:40.000000000 -0700
> @@ -12,9 +12,9 @@
> 
>      def createToplevelWidget(self, classname, widgetname):
>          if self.toplevelInst is not None:
> -            if not isinstance(self.toplevelInst, self.wdb[classname]):
> +            if not isinstance(self.toplevelInst, self.wdb.findQObjectType(classname)):
>                  raise TypeError, ("Wrong base class of toplevel widget",
> -                                  (type(self.toplevelInst), self.wdb[classname]))
> +                                  (type(self.toplevelInst), classname))
>              return self.toplevelInst
>          else:
>              return self.wdb.createQObject(classname, widgetname, ())
> Only in pyuic/uic: autoconnect.py
> diff -ru PyQt-win-gpl-4-snapshot-20060930/pyuic/uic/objcreator.py pyuic/uic/objcreator.py
> --- PyQt-win-gpl-4-snapshot-20060930/pyuic/uic/objcreator.py    2006-10-11 10:06:58.000000000 -0700
> +++ pyuic/uic/objcreator.py     2006-10-11 10:07:54.000000000 -0700
> @@ -50,14 +50,17 @@
> 
> 
>      def createQObject(self, classname, *args, **kwargs):
> +        classType = self.findQObjectType(classname)
> +        if classType:
> +            return self._cpolicy.instantiate(classType, *args, **kwargs)
> +        raise NoSuchWidgetError, classname
> +
> +    def findQObjectType(self, classname):
>          for module in self._modules:
>              w = module.search(classname)
>              if w is not None:
> -                return self._cpolicy.instantiate(w, *args, **kwargs)
> -        else:
> -            raise NoSuchWidgetError, cls
> -
> -        raise NotImplementedEror, "must be overridden by subclasses"
> +                return w
> +        return None
> 
> 
>      def getSlot(self, object, slotname):

Hi,

your patch was of course correct, it should appear in one of the next snapshots.

Thanks a lot!

best,

Torsten
- --
Torsten Marek <shlomme at gmx.net>
ID: A244C858 -- FP: 1902 0002 5DFC 856B F146  894C 7CC5 451E A244 C858
Keyserver: subkeys.pgp.net

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFOlXRfMVFHqJEyFgRAr/8AKCiehIT7OKYbXDFQACuWZatUsfXrQCfW5mg
k7ADTSKQgJY77Z504B+vxZ4=
=ah1H
-----END PGP SIGNATURE-----




More information about the PyQt mailing list