I am using the QGIS plugin builder 3 with Qt Designer to create the GUI for my plugin. I've got a basic GUI done with QtDesigner and I need to dynamically populate a container in my GUI using python. I am struggling to write the python code for this without having a proper look at the python file generated by the builder using the .ui file. I've tried doing it manually using commands like the following:
C:\path_to_pyuic\pyuic.py -o ui_form.py form.ui
When I do this, it struggles to find PyQT related packages. I get the following error:
No module named PyQt5
But when I run the plugin on QGIS, the GUI pops up perfectly and everything runs smooth. It would be great if someone can point out a quick and easy way to access the .py file generated by the builder. I am not super sure if it is actually generated but it would be ideal if it is accessible in some way.
cd C:\path\to\location\of\form.ui
thenpyuic5 form.ui -o form.py
I haven't used plugin builder for quite a while but iirc, it doesn't convert.ui
to.py
but rather usesuic.loadUiType()
method, which you can see in the generated file:plugin_name_dialog.py
. BTW did you change the.ui
name? I thought plugin builder generated.ui
file is usually named like:plugin_name_dialog_base.ui
.self.dlg.objectName
. You can inspect or edit the object names and classes in your.ui
file inside QtDesigner. Once you have a reference to your ui objects, you can access any PyQt methods belonging to the object class or parent classes.