[PyQt] uic NoSuchWidgetError

Phil Thompson phil at riverbankcomputing.com
Tue Dec 9 18:38:22 GMT 2008


On Tue, 09 Dec 2008 19:08:41 +0100, Matteo Bertini <naufraghi at develer.com>
wrote:
> Searching for Q3 in my code I found this:
> Don't you think filtering a name is not a very polite method?
> Is'nt it better letting python rise an exception if the Widget is not 
> found at runtime?
> 
> Cheers,
> Matteo Bertini
> 
> Index: PyQt-x11-gpl-4.4.4/pyuic/uic/pyuic.py
>
================================================================================
> --- PyQt-x11-gpl-4.4.4/pyuic/uic/pyuic.py (original)
> +++ PyQt-x11-gpl-4.4.4/pyuic/uic/pyuic.py (modified)
> @@ -78,8 +78,8 @@
>       sys.stderr.write("Error in input file: %s\n" % e)
> 
>   except uic.exceptions.NoSuchWidgetError, e:
> -    if e.args[0].startswith("Q3"):
> -        sys.stderr.write("Error: Q3Support widgets are not supported by 
> PyQt4.\n")
> +    if e.args[0].startswith("QX"):
> +        sys.stderr.write("Error: QXSupport widgets are not supported by 
> PyQt4.\n")
>       else:
>           sys.stderr.write(str(e) + "\n")
> 
> Index: PyQt-x11-gpl-4.4.4/pyuic/uic/uiparser.py
>
================================================================================
> --- PyQt-x11-gpl-4.4.4/pyuic/uic/uiparser.py (original)
> +++ PyQt-x11-gpl-4.4.4/pyuic/uic/uiparser.py (modified)
> @@ -650,7 +650,7 @@
> 
>           for custom_widget in iter(elem):
>               classname = custom_widget.findtext("class")
> -            if classname.startswith("Q3"):
> +            if classname.startswith("QX"):
>                   raise NoSuchWidgetError, classname
>               self.factory.addCustomWidget(classname,
>                                        custom_widget.findtext("extends") 
> or "QWidget",

That code is converting the exception to a user error message when they are
running pyuic4 from the command line - so it's doing what it should.

Phil


More information about the PyQt mailing list