TypeError: setLayoutDirection(self, Qt.LayoutDirection): argument 1 has unexpected type 'ProxyMetaclass'

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

TypeError: setLayoutDirection(self, Qt.LayoutDirection): argument 1 has unexpected type 'ProxyMetaclass'

Kyle Altendorf
While reworking my code to correct the errors related to my previous
message I ran into another exception loading .ui files.  This one
doesn't seem to be related to 3.7.4 specifically and I ran my test all
the way back to pyqt5.8 with the latest micro for each minor version
failing.

Code and output at:
     https://gist.github.com/altendky/151ddfdab48d566330a2ad8099229153

The traceback ends up at:
       File
"/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/properties.py",
line 417, in setProperties
         getattr(widget, 'set%s%s' % (ascii_upper(prop_name[0]),
prop_name[1:]))(prop_value)
     TypeError: setLayoutDirection(self, Qt.LayoutDirection): argument 1
has unexpected type 'ProxyMetaclass'

Cheers,
-kyle
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: TypeError: setLayoutDirection(self, Qt.LayoutDirection): argument 1 has unexpected type 'ProxyMetaclass'

Phil Thompson-5
On 04/08/2019 03:04, Kyle Altendorf wrote:

> While reworking my code to correct the errors related to my previous
> message I ran into another exception loading .ui files.  This one
> doesn't seem to be related to 3.7.4 specifically and I ran my test all
> the way back to pyqt5.8 with the latest micro for each minor version
> failing.
>
> Code and output at:
>     https://gist.github.com/altendky/151ddfdab48d566330a2ad8099229153
>
> The traceback ends up at:
>       File
> "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/properties.py",
> line 417, in setProperties
>         getattr(widget, 'set%s%s' % (ascii_upper(prop_name[0]),
> prop_name[1:]))(prop_value)
>     TypeError: setLayoutDirection(self, Qt.LayoutDirection): argument
> 1 has unexpected type 'ProxyMetaclass'

Putting everything in the one script is probably causing problems, ie.
the script that loads the UI also defines the custom widget which means
the script is run twice (and maybe it would recurse if there was no
exception).

Phil
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: TypeError: setLayoutDirection(self, Qt.LayoutDirection): argument 1 has unexpected type 'ProxyMetaclass'

Kyle Altendorf
On 2019-08-04 13:14, Phil Thompson wrote:

> On 04/08/2019 03:04, Kyle Altendorf wrote:
>> While reworking my code to correct the errors related to my previous
>> message I ran into another exception loading .ui files.  This one
>> doesn't seem to be related to 3.7.4 specifically and I ran my test all
>> the way back to pyqt5.8 with the latest micro for each minor version
>> failing.
>>
>> Code and output at:
>>     https://gist.github.com/altendky/151ddfdab48d566330a2ad8099229153
>>
>> The traceback ends up at:
>>       File
>> "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/properties.py",
>> line 417, in setProperties
>>         getattr(widget, 'set%s%s' % (ascii_upper(prop_name[0]),
>> prop_name[1:]))(prop_value)
>>     TypeError: setLayoutDirection(self, Qt.LayoutDirection): argument
>> 1 has unexpected type 'ProxyMetaclass'
>
> Putting everything in the one script is probably causing problems, ie.
> the script that loads the UI also defines the custom widget which
> means the script is run twice (and maybe it would recurse if there was
> no exception).

This started with an error in my real many-file application.  I first
recreated it in multiple files for the example then compacted down to
one.  There was recursion because I forgot to add in `if __name__...` so
I did.  Here is a copy of the example split back into two files.

https://gist.github.com/altendky/93657f6748a94f1b10316dd4884d65a7

Cheers,
-kyle
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: TypeError: setLayoutDirection(self, Qt.LayoutDirection): argument 1 has unexpected type 'ProxyMetaclass'

Kyle Altendorf


On 2019-08-04 13:45, Kyle Altendorf wrote:

> On 2019-08-04 13:14, Phil Thompson wrote:
>> On 04/08/2019 03:04, Kyle Altendorf wrote:
>>> While reworking my code to correct the errors related to my previous
>>> message I ran into another exception loading .ui files.  This one
>>> doesn't seem to be related to 3.7.4 specifically and I ran my test
>>> all
>>> the way back to pyqt5.8 with the latest micro for each minor version
>>> failing.
>>>
>>> Code and output at:
>>>     https://gist.github.com/altendky/151ddfdab48d566330a2ad8099229153
>>>
>>> The traceback ends up at:
>>>       File
>>> "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/properties.py",
>>> line 417, in setProperties
>>>         getattr(widget, 'set%s%s' % (ascii_upper(prop_name[0]),
>>> prop_name[1:]))(prop_value)
>>>     TypeError: setLayoutDirection(self, Qt.LayoutDirection): argument
>>> 1 has unexpected type 'ProxyMetaclass'
>>
>> Putting everything in the one script is probably causing problems, ie.
>> the script that loads the UI also defines the custom widget which
>> means the script is run twice (and maybe it would recurse if there was
>> no exception).
>
> This started with an error in my real many-file application.  I first
> recreated it in multiple files for the example then compacted down to
> one.  There was recursion because I forgot to add in `if __name__...`
> so I did.  Here is a copy of the example split back into two files.
>
> https://gist.github.com/altendky/93657f6748a94f1b10316dd4884d65a7


Adding `import bad2a` prior to the `PyQt5.uic.loadUi()` call avoids the
exception in this example.  I know a 'similar' situation and solution
came up awhile back and I brought it up on the list.  A quick search
didn't turn it up in the maillist archive but as I recall the resolution
was that the uic stuff doesn't really support loading one .ui which
triggers loading another .ui.  There was some magic with Qt modules
being overwritten or such global state which caused issues.  I'll go
take a look at actually switching to regular compilation of the .ui
files and then importing the resultant .py files to avoid all this.  The
dynamic loading is nice but it seems not robust enough for the pile I
have created.

Cheers,
-kyle
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: TypeError: setLayoutDirection(self, Qt.LayoutDirection): argument 1 has unexpected type 'ProxyMetaclass'

Phil Thompson-5
In reply to this post by Kyle Altendorf
On 04/08/2019 18:45, Kyle Altendorf wrote:

> On 2019-08-04 13:14, Phil Thompson wrote:
>> On 04/08/2019 03:04, Kyle Altendorf wrote:
>>> While reworking my code to correct the errors related to my previous
>>> message I ran into another exception loading .ui files.  This one
>>> doesn't seem to be related to 3.7.4 specifically and I ran my test
>>> all
>>> the way back to pyqt5.8 with the latest micro for each minor version
>>> failing.
>>>
>>> Code and output at:
>>>     https://gist.github.com/altendky/151ddfdab48d566330a2ad8099229153
>>>
>>> The traceback ends up at:
>>>       File
>>> "/home/altendky/tmp/venv3.7.4/lib/python3.7/site-packages/PyQt5/uic/properties.py",
>>> line 417, in setProperties
>>>         getattr(widget, 'set%s%s' % (ascii_upper(prop_name[0]),
>>> prop_name[1:]))(prop_value)
>>>     TypeError: setLayoutDirection(self, Qt.LayoutDirection): argument
>>> 1 has unexpected type 'ProxyMetaclass'
>>
>> Putting everything in the one script is probably causing problems, ie.
>> the script that loads the UI also defines the custom widget which
>> means the script is run twice (and maybe it would recurse if there was
>> no exception).
>
> This started with an error in my real many-file application.  I first
> recreated it in multiple files for the example then compacted down to
> one.  There was recursion because I forgot to add in `if __name__...`
> so I did.  Here is a copy of the example split back into two files.
>
> https://gist.github.com/altendky/93657f6748a94f1b10316dd4884d65a7

You have to separate the MyWidget implementation from the call to
loadUiType() so that loadUiType() can be called before loadUi().

The root cause is that loadUiType() is implemented by compiling the XML
to Python code and then executing that code. The compilation process
uses proxies for the various PyQt objects.

loadUi() creates the PyQt objects directly (no proxies).

With your code loadUiType() is being called from within loadUi() and
things get confused.

Phil
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt