[GIS] User Interface file compilation using OSGeo4W shell during qgis plugin creation

osgeo4wpyqgisqgis-2

I am trying to build a plugin in Qgis2.6 using plugin builder. And as a part of the same, I tried compiling the .ui and .qrc file using OSGeo4W shell. It is showing an error during compilation in OSGeo4W shell. Please help me how to compile the ui as well as qrc file using OSGeo4W shell or reply me where I am wrong from the below attached error. I am new in QGis plugin creation. The plugin contents inside the folder also attached.

enter image description here

enter image description here

Best Answer

I will write a quick explanation of the pyuic4 and pyrcc4 commands for future reference. Most tutorials simply tell you to copy some code, but no one explains exactly what you are about to do. It is quite simple actually, but beginners might still struggle with it.

The Plugin Builder generates a fairly 'empty' plugin template. The two files that are of interest to us, as we need to convert them to Python files manually, are the GUI file (.ui) and the resource file (.qrc).

Let us assume my Plugin Builder leaves me with the following files when creating a template for a plugin that I named Color Changer: color_changer_dialog_base.ui and resources.qrc.

Now, to convert these files to Python (.py) files we need to move to a console (for example, the OSGeo4W Shell).

The syntax for the GUI conversion is:
pyuic4 -o nameOfTheFileWeWantToCreate.py nameOfOurExistingFile.ui

As in:

pyuic4 -o color_changer_dialog_base.py color_changer_dialog_base.ui


And the syntax for the resource file is:
pyrcc4 -o nameOfTheFileWeWantToCreate.py nameOfOurExistingFile.qrc

As in:

pyrcc4 -o resources_rc.py resources.qrc


Of course, all rules that generally apply in GIS or programming should be considered. In your case, consider not using blank spaces in file names.




So, this:
before conversion

through this:
OSGeo4W Shell

will become this:
after conversion