Wednesday 6 April 2016

pyqgis - Compiling resources in QGIS 2.99 (Windows) for creating plugin?


I tried out to create, for Windows, the Where Am I? QGIS 2.99 plugin (similar to Gary Sherman's book) by using Plugin Builder 3. In spite of being created, it was generated an error that it can be visualized in following image:


enter image description here



and this is an extract of produced text:



TypeError: keyPressEvent(self, QKeyEvent): first argument of unbound method must have type 'QDialog'


Traceback (most recent call last):
File "C:/Users/Usuario/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\pluginbuilder3\plugin_builder_dialog.py", line 169, in keyPressEvent QDialog.keyPressEvent(event) TypeError: keyPressEvent(self, QKeyEvent): first argument of unbound method must have type 'QDialog'



However, I think that it could be not important because I found out that is was always produced by pressing Shift key.


As I don't have compilation resources in Windows, plugin was compilated (pyqt5-dev-tools) in my Debian GNU/Linux with make (without any error):


pyrcc5 -o resources.py resources.qrc


Afterward, it was newly exported to Windows at folder:


C:\Users\Usuario\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins 

When I try to activate plugin, I got that it is not compatible for this version of QGIS; as it can be observed at following image:


enter image description here


When I open folder of each installed plugin (reloader, builder, zoom to Belgium), at top they always have a __pycache__ folder; as it can be observed at following image:


enter image description here


However, created plugin doesn't:


enter image description here


I also corroborated that resources.py was adequately compilated because it has this header:



# -*- coding: utf-8 -*-

# Resource object code
#
# Created: Mon Nov 27 15:50:04 2017
# by: The Resource Compiler for PyQt (Qt v5.3.2)
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore

.
.
.

and similar structure in all plugins (however my compiler version for PyQt is older; v5.3.2 vs v5.7.1).


My question is why was not adequately produced __pycache__ folder with Plugin Builder 3 or plugins created by user need to be placed in another folder in Windows environment?


Editing Note:


After creating Where Am I? plugin, I edited Qt5 objects in Qt5Designer from Linux and I included required lines to show location of a point click on the map; as it can be observed at following image. Plugin works as expected.


enter image description here



Answer




Check the metadata.txt file of your plugin to make sure the qgisMinimumVersion is set properly.


Compare the settings in metadata.txt for other working plugins for examples.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...