<div dir="ltr">Hi Ludovic,<div><br></div><div>I am not modifying the built resources_rc.py but the import one I am using in the same directory than the dialog file.</div><div>This resources_rc.py only contains the import statement, I have successfully used this when using pyuic in the past, but it doesn't seem to work when using loadUiType.</div><div><br></div><div>More generally, I am wondering what is the approach when the resources_rc.py, the ui and the dialog py files are all 3 in distinct directories.</div><div><br></div><div>Cheers,</div><div>Denis</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 17 janv. 2020 à 15:34, Ludovic Bellière <<a href="mailto:belliere.ludovic@proximus.be">belliere.ludovic@proximus.be</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello Denis,<br>
<br>
The resources_rc.py is supposed to be generated with pyrcc5, and<br>
shouldn't be edited. The structure of your application is weird, and<br>
apparently the loader is unable to find your resources_rc.py, which<br>
means you didn't put it where it needs to be. I don't know where it<br>
needs to be, it depends on the structure of your code, and files within<br>
your project.<br>
<br>
Do you know how python imports works? You see confused on that subject.<br>
Did you consider building a test PyQt5 app using a flat format, and then<br>
expand from there?<br>
<br>
Cheers,<br>
Ludovic<br>
<br>
PS: sorry about the previous direct e-mail. Still figuring ML stuff out.<br>
<br>
On 17/01/20 14:58, Denis Rouzaud wrote:<br>
> Hi Ludovic,<br>
> <br>
> Thanks for the help.<br>
> <br>
> I tried to add this in my resources_rc.py in the same path than the<br>
> dialog py file without success.<br>
> I also tried in the __init__.py<br>
> <br>
> Where is it meant to live?<br>
> <br>
> Cheers,<br>
> Denis<br>
> <br>
> Le ven. 17 janv. 2020 à 14:27, Ludovic Bellière<br>
> <<a href="mailto:belliere.ludovic@proximus.be" target="_blank">belliere.ludovic@proximus.be</a> <mailto:<a href="mailto:belliere.ludovic@proximus.be" target="_blank">belliere.ludovic@proximus.be</a>>> a<br>
> écrit :<br>
> <br>
> Hello Denis,<br>
> <br>
> The compiled resources_rc.py has a bit of code that will inject the<br>
> different resources into Qt's database at the time of import. To achieve<br>
> that, you need to do the import this way:<br>
> <br>
> `from .. import resources_rc`<br>
> <br>
> On 16/01/20 11:29, Denis Rouzaud wrote:<br>
> > Hi list,<br>
> ><br>
> > I have this tree structure:<br>
> > - gui<br>
> > |- dialog.py<br>
> > - ui<br>
> > |- dialog.ui<br>
> > - resources_rc.py<br>
> ><br>
> > I am trying to use uic.loadUiType with the ui file having a resources<br>
> > file defined integrated with:<br>
> ><br>
> > <iconset resource="../resources.qrc"><br>
> > <br>
> <normaloff>:/plugins/qfieldsync/visibility.svg</normaloff>:/plugins/qfieldsync/visibility.svg</iconset><br>
> > </property><br>
> ><br>
> ><br>
> ><br>
> > I have this error:<br>
> ><br>
> > File "/Users/denis/Library/Application<br>
> ><br>
> Support/QGIS/QGIS3/profiles/default/python/plugins/qfieldsync/gui/project_configuration_dialog.py",<br>
> > line 36, in<br>
> > os.path.join(os.path.dirname(__file__),<br>
> > '../ui/project_configuration_dialog.ui'),<br>
> > File<br>
> ><br>
> "/Applications/QGIS3.11.app/Contents/MacOS/../Resources/python/qgis/PyQt/uic/__init__.py",<br>
> > line 36, in __loadUiType<br>
> > return __PyQtLoadUiType(*args, **kwargs)<br>
> > File<br>
> ><br>
> "/Applications/QGIS3.11.app/Contents/MacOS/../Resources/python/PyQt5/uic/__init__.py",<br>
> > line 201, in loadUiType<br>
> > exec(code_string.getvalue(), ui_globals)<br>
> > File "", line 182, in<br>
> > File<br>
> ><br>
> "/Applications/QGIS3.11.app/Contents/MacOS/../Resources/python/qgis/utils.py",<br>
> > line 737, in _import<br>
> > mod = _builtin_import(name, globals, locals, fromlist, level)<br>
> > ModuleNotFoundError: No module named 'resources_rc'<br>
> ><br>
> ><br>
> ><br>
> ><br>
> > I tried to add a resources_rc.py in the gui folder with:<br>
> ><br>
> > from ..resources_rc import *<br>
> ><br>
> > but this doesn't help.<br>
> ><br>
> ><br>
> > And if I use the option from_imports=True (in loadUiType), I am<br>
> getting:<br>
> ><br>
> > line 37, in<br>
> > from_imports=True<br>
> > File<br>
> ><br>
> "/Applications/QGIS3.11.app/Contents/MacOS/../Resources/python/qgis/PyQt/uic/__init__.py",<br>
> > line 36, in __loadUiType<br>
> > return __PyQtLoadUiType(*args, **kwargs)<br>
> > File<br>
> ><br>
> "/Applications/QGIS3.11.app/Contents/MacOS/../Resources/python/PyQt5/uic/__init__.py",<br>
> > line 201, in loadUiType<br>
> > exec(code_string.getvalue(), ui_globals)<br>
> > File "", line 182, in<br>
> > File<br>
> ><br>
> "/Applications/QGIS3.11.app/Contents/MacOS/../Resources/python/qgis/utils.py",<br>
> > line 737, in _import<br>
> > mod = _builtin_import(name, globals, locals, fromlist, level)<br>
> > KeyError: "'__name__' not in globals"<br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> > How am I suppose to handle this?<br>
> > Thanks,<br>
> ><br>
> > Denis<br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
> <mailto:<a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a>><br>
> > <a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="noreferrer" target="_blank">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
> ><br>
> <br>
</blockquote></div>