Hi Julierme,

I see, you want the images to be used in the GUI.

Strange that a plugin reload fixes the problem and I cannot tell you why. The only thing I noticed is that the 'import error' is trying to import module 'resources_rc' and your python file is called 'resources.py' (and not 'resources_rc.py')

Could it be that your code at some place contains

import resources_rc

(or from resources_rc import ...)

And that that part of the code only runs at QGIS startup?? Sorry, I'm just guessing here.

Is your code on github or something similar?

Cheers,
Raymond

PS I'm replying to the user list again, so others can help and find this conversation in the future.



On 23-10-2020 16:45, 1520 gis wrote:


On Fri, Oct 23, 2020 at 11:35 AM 1520 gis <juliermeopensourcedevelo...@gmail.com <mailto:juliermeopensourcedevelo...@gmail.com>> wrote:

    Dear Raymond

    Thank you very much for your reply. As you can see from
    resources.qrc file config above, I am trying to add to logo png
    images plus the plugin icon. I am doing this straight from Qt
    Designer. I am adding three pixmap in three different labels. Either
    choose Resource or choose File  and after that running  <pb_tool
    compile> and <pyrcc5 -o resources.py resources.qrc> keeps showing an
    error message ModuleNotFoundError: No module named 'resources_rc'
    after qgis restart.
    However if I run qgis Reload Plugin, my plugin shows up.

    I appreciated your time. I will send a video attached.


    On Fri, Oct 23, 2020 at 10:27 AM Raymond Nijssen
    <r.nijs...@terglobo.nl <mailto:r.nijs...@terglobo.nl>> wrote:

        Hi Julierme,

        You need(ed) to convert the .qrc file to a .py file with rcc. See:
        
https://doc.qt.io/qt-5/resources.html#resources-in-a-qt-for-python-application


        But personally I'm not using it anymore, cause you can just use
        the .png
        files straight in your code and I find it easier.

        For example, I make a toolbar button with icon this way:

        ```
        icon = QIcon(os.path.join(self.plugin_dir, 'icon.png'))
        self.action = QAction(icon, 'Do something', self.iface.mainWindow())
        self.action.triggered.connect(self.run_something)
        self.toolbar.addAction(self.action)
        ```

        Hope it helps!
        Raymond


        On 22-10-2020 21:46, 1520 gis wrote:
         > Dear all,
         >
         > I have created a Qgis plugin and I use three images in the
        resources.qrc
         > file shown below. Everything works fine before I restart
        Qgis. If I
         > restart Qgis, I hit an error ModuleNotFoundError: No module
        named
         > 'resources_rc'. And the plugin won't start. Any comment will
        be very
         > appreciated.
         >
         > Thank you for your time in advance.
         >
         > Kind regards
         >
         > Julierme
         >
         > <RCC>
         > <qresource prefix="/plugins/inde" >
         > <file>icon.png</file>
         > <file>censipamLogo.png</file>
         > <file>indeLogo.png</file>
         > </qresource>
         > </RCC>
         >
         >
         > _______________________________________________
         > Qgis-user mailing list
         > Qgis-user@lists.osgeo.org <mailto:Qgis-user@lists.osgeo.org>
         > List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
         > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
         >
        _______________________________________________
        Qgis-user mailing list
        Qgis-user@lists.osgeo.org <mailto:Qgis-user@lists.osgeo.org>
        List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
        Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to