[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Problem with resource imports in pyuic generated files
From:       Elvis Stansvik <elvstone () gmail ! com>
Date:       2016-02-17 5:06:10
Message-ID: CAHms=eZcLi=zaBxWM8FAXv8D4QH=a4DQ3_B14GCFsyN1raBMQQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Den 16 feb 2016 10:00 em skrev "Baz Walter" <bazwal@ftml.net>:
>
> On 16/02/16 18:56, Elvis Stansvik wrote:
>>
>> 2016-02-16 19:54 GMT+01:00 Elvis Stansvik <elvstone@gmail.com>:
>>>
>>> 2016-02-16 19:35 GMT+01:00 Baz Walter <bazwal@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@riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[Attachment #5 (text/html)]

<p dir="ltr">Den 16 feb 2016 10:00 em skrev &quot;Baz Walter&quot; &lt;<a \
href="mailto:bazwal@ftml.net">bazwal@ftml.net</a>&gt;:<br> &gt;<br>
&gt; On 16/02/16 18:56, Elvis Stansvik wrote:<br>
&gt;&gt;<br>
&gt;&gt; 2016-02-16 19:54 GMT+01:00 Elvis Stansvik &lt;<a \
href="mailto:elvstone@gmail.com">elvstone@gmail.com</a>&gt;:<br> &gt;&gt;&gt;<br>
&gt;&gt;&gt; 2016-02-16 19:35 GMT+01:00 Baz Walter &lt;<a \
href="mailto:bazwal@ftml.net">bazwal@ftml.net</a>&gt;:<br> &gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; So the python package directory contains python modules and nothing \
else.<br> &gt;&gt;&gt;&gt; The resource module generated by pyrcc just goes in the \
same directory as<br> &gt;&gt;&gt;&gt; the ones generated by pyuic, which solves the \
import issue.<br> &gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Ah yes, probably a good idea to to break the .ui files out of the<br>
&gt;&gt;&gt; python package as well. Thanks.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; For now, I&#39;ll have to keep the generated _ui.py and _rc.py in the \
same<br> &gt;&gt;&gt; package. This is okay, but I would rather have them split up \
(e.g. a<br> &gt;&gt;&gt; ui/ or perhaps forms/ package with the .ui files, and a \
resources/<br> &gt;&gt;&gt; package for the resources). So for me, something like \
a<br> &gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; I should say, the reason I&#39;d prefer to be able to do this is that \
some<br> &gt;&gt; of my resources are not really &quot;UI&quot; things per se, but \
more like<br> &gt;&gt; static application data, so it would make more sense to have a \
general<br> &gt;&gt; &quot;resources&quot; package for them.<br>
&gt;&gt;<br>
&gt;<br>
&gt; 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).</p> <p dir="ltr">That&#39;s a good point. I \
think the reason I wanted a resources package is that I&#39;m abusing the resource \
system a little, by having </p> <p dir="ltr">icons.qrc<br>
images.qrc<br>
rock_types.qrc<br>
mineral_types.qrc<br>
...</p>
<p dir="ltr">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.</p> <p dir="ltr">I \
realize now that that&#39;s not such a great idea, and will stuff it all in a single \
resources.qrc.</p> <p dir="ltr">I was structuring the contained files across separate \
directories anyway, which gives nice namespaces in the :/foo paths used.</p> <p \
dir="ltr">Thanks for the input!</p> <p dir="ltr">Though, Phil, I cannot help but ask: \
Would you accept a patch for a --resources-package &lt;package&gt; 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.</p> <p \
dir="ltr">Elvis </p> <p dir="ltr">&gt;<br>
&gt;<br>
&gt; -- <br>
&gt; Regards<br>
&gt; Baz Walter<br>
&gt; _______________________________________________<br>
&gt; PyQt mailing list      <a \
href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br> &gt; <a \
href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></p>



[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic