[PyQt] Problem with resource imports in pyuic generated files

Elvis Stansvik elvstone at gmail.com
Wed Feb 17 05:06:10 GMT 2016


Den 16 feb 2016 10:00 em skrev "Baz Walter" <bazwal at ftml.net>:
>
> On 16/02/16 18:56, Elvis Stansvik wrote:
>>
>> 2016-02-16 19:54 GMT+01:00 Elvis Stansvik <elvstone at gmail.com>:
>>>
>>> 2016-02-16 19:35 GMT+01:00 Baz Walter <bazwal at ftml.net>:
>>>>
>>>> So the python package directory contains python modules and nothing
else.
>>>> The resource module generated by pyrcc just goes in the same directory
as
>>>> the ones generated by pyuic, which solves the import issue.
>>>
>>>
>>> Ah yes, probably a good idea to to break the .ui files out of the
>>> python package as well. Thanks.
>>>
>>> For now, I'll have to keep the generated _ui.py and _rc.py in the same
>>> package. This is okay, but I would rather have them split up (e.g. a
>>> ui/ or perhaps forms/ package with the .ui files, and a resources/
>>> package for the resources). So for me, something like a
>>
>>
>> I should say, the reason I'd prefer to be able to do this is that some
>> of my resources are not really "UI" things per se, but more like
>> static application data, so it would make more sense to have a general
>> "resources" package for them.
>>
>
> The modules generated by pyuic will probably be the only ones that
explicitly import the resources module. What would be the point of a
separate sub-package? From a programming point of view, the only namespace
that matters is the one provided by the resource system itself - and the
best place to organize that is the qrc file (it has support for aliases, if
needed).

That's a good point. I think the reason I wanted a resources package is
that I'm abusing the resource system a little, by having

icons.qrc
images.qrc
rock_types.qrc
mineral_types.qrc
...

Not all of which are used only from UI forms, so some would need to be
imported from manual code, such as in the item delegate I pasted.

I realize now that that's not such a great idea, and will stuff it all in a
single resources.qrc.

I was structuring the contained files across separate directories anyway,
which gives nice namespaces in the :/foo paths used.

Thanks for the input!

Though, Phil, I cannot help but ask: Would you accept a patch for a
--resources-package <package> flag to pyuic? When given, it would generate
resource imports from the named package instead of assuming resources were
generated into the same package as the _ui.py.

Elvis

>
>
> --
> Regards
> Baz Walter
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160217/c3ea0177/attachment.html>


More information about the PyQt mailing list