Imagina tener una gran idea para darle aún más potencia a tu QGIS y poder hacerlo con un lenguaje simple, Python.
¡Aquí se explica cómo crear un complemento Qgis!
Un plugin para hacer otro plugin
Instale el plugins builder 3 , que se describe a sí mismo, acertadamente, como «Crea una plantilla de complemento QGIS para usar como punto de partida en el desarrollo de complementos».
Installate il plugins builder 3 che si descrive, giustamente, come «Creates a QGIS plugin template for use as a starting point in plugin development».
Ademas de esta pagina, te aconsejo unos recursos on line:
QGis tutorial – Plugin development – part 1
u Rob
i 29K views
⇑ Jan 15 2021
Advertencia, durante la instalación, ignore este mensaje:
The resource compiler pyrcc5 was not found in your path. You’ll have to manually compile the resources.qrc file with pyrcc5 before installing your plugin.
Al ejecutar el Plugin Builder 3, se te solicitará que proporciones detalles como el nombre del plugin y la ubicación de destino deseada. Ten en cuenta que los archivos del plugin generados podrían no colocarse en el directorio que prefieres; probablemente tendrás que moverlos manualmente a la ubicación deseada. También se requiere información adicional como el correo electrónico del desarrollador, el estado de estabilidad (si se considera una versión estable o no) y el nombre de la versión.
Veras un texto parecido a lo que sigue.
Plugin Builder Results
Congratulations! You just built a plugin for QGIS!
Your plugin AndreaPluginCourse was created in:
/Users/ndrini/workspace/ndrini/pyqgis/my_plugins/ndrini_plugin.py
Your QGIS plugin directory is located at:
/Users/ndrini/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins
What’s Next
- If resources.py is not present in your plugin directory, compile the resources file using pyrcc5 (simply use pb_tool or make if you have automake)
- Optionally, test the generated sources using make test (or run tests from your IDE)
- Copy the entire directory containing your new plugin to the QGIS plugin directory (see Notes below)
- Test the plugin by enabling it in the QGIS plugin manager
- Customize it by editing the implementation file andrea_plugin_course.py.py
- Create your own custom icon, replacing the default icon.png
- Modify your user interface by opening andrea_plugin_course.py_dialog_base.ui in Qt Designer
Notes:
- You can use pb_tool to compile, deploy, and manage your plugin. Tweak the pb_tool.cfg file included with your plugin as you add files. Install pb_tool using pip or easy_install. See http://loc8.cc/pb_tool for more information.
- You can also use the Makefile to compile and deploy when you make changes. This requires GNU make (gmake). The Makefile is ready to use, however you will have to edit it to add addional Python source files, dialogs, and translations.
For information on writing PyQGIS code, see http://loc8.cc/pyqgis_resources for a list of resources.
©2011-2019 GeoApt LLC – geoapt.com
def test(self):
«»» This method allows to dialog with the user.»»»«»» User communication: QgsMessageBar «»»
print(«Message printed into the QGIS’s Python console»)
# # Show messages in QGIS message bar
message_bar = iface.messageBar()
print(type(message_bar))message_bar.pushMessage(«Title», «Info message», Qgis.Info, 100)
message_bar.pushMessage(«», «Warning message», Qgis.Warning, 10)message_bar.pushMessage(«», «Don’t worry. This `Critical message` is an expected failure 😂», Qgis.Critical)