QGIS Plugins – How to Compile Plugin Builder Plugin in QGIS 2.4 on Windows

errorqgisqgis-plugins

I'm trying to build a basic plugin using plugin builder but I can't even compile it. I tried following a few tutorials and just trying to compile whatever but that always results in the same problem.

Error messages for rcc4.exe and uic4.bin:

"C:\Program Files\QGIS Chugiak\bin\pyrcc4" -o my_plugin.py my_plugin_dialog_base.ui
No resources in resource description.   

"C:\Program Files\QGIS Chugiak\bin\pyuic4" -o my_plugin.py my_plugin_dialog_base.ui
ImportError: No module named site

relevant files in the plugin folder:

my_plugin.py
my_plugin_dialog.py
my_plugin_dialog_base.ui
resources.qrc

What's in the /bin folder:

pyrcc4.exe
pyuic4.bat
pyuic4.bat.tmpl

Any idea what's wrong? I'm limited to using whatever's installed with QGIS to compile this, by the way.

Best Answer

You only need to run

pyrcc4 -o resources_rc.py resources.qrc

The .ui file is loaded dynamically in the recent versions of the default plugin code. For example, if the plugin is called test, the corresponding GUI loading code in test_dialog.py is

FORM_CLASS, _ = uic.loadUiType(os.path.join(
   os.path.dirname(__file__), 'test_dialog_base.ui'))

All necessary instructions are provided in the Plugin Builder popup which appears after the plugin is created.

Related Question