g-sherman / qgis-plugin-builder Goto Github PK
View Code? Open in Web Editor NEWPlugin generator for creating QGIS Python plugins (QGIS 3 version is now in master)
Plugin generator for creating QGIS Python plugins (QGIS 3 version is now in master)
After a emailing thread on the dev list about translation [0], I think it would be cool if we move the Makefile/shell scripts to maybe Paver/python?
In that way the stuff can be ran on Win/Lin/Mac.
Although this will probably not be a simple task, I think it would be nice to have?
[0] https://lists.osgeo.org/pipermail/qgis-developer/2016-March/thread.html#42063
Talked about this with @timlinux last PSC.
Hi Tim, I needed the pluginbuilder, which failed to load due to missing QWebKit, changed the QWebView in the ui file to a QTextBrowser (but named it web_view) again, and it worked.
The Result dialog looks like this then:
So: what to do: create a second results_dialog_base.ui (named results_dialog_base_without_webkit.ui)
and change
https://github.com/g-sherman/Qgis-Plugin-Builder/blob/master/result_dialog.py#L28
to a try/catch with tries to load the 'without'-version after a failing of the normal one?
happy to try this if you want and do a pull request. Not sure if you want the content of the dialog to be changed (for example an image must be in resources instead of filebased one).
I'll upload current ui file too:
Hi there, I have tried to install Plugin Builder on my Linux Red Hat 7 System and I got an error.
Couldn't load plugin pluginbuilder due to an error when calling its classFactory() method
Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/qgis/utils.py", line 219, in startPlugin
plugins[packageName] = package.classFactory(iface)
File "/home/qgisosr/.qgis2/python/plugins/pluginbuilder/init.py", line 34, in classFactory
from .plugin_builder import PluginBuilder
File "/usr/lib64/python2.7/site-packages/qgis/utils.py", line 478, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/home/qgisosr/.qgis2/python/plugins/pluginbuilder/plugin_builder.py", line 46, in
from result_dialog import ResultDialog
File "/usr/lib64/python2.7/site-packages/qgis/utils.py", line 478, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/home/qgisosr/.qgis2/python/plugins/pluginbuilder/result_dialog.py", line 29, in
os.path.dirname(file), 'results_dialog_base.ui'))
File "/usr/lib64/python2.7/site-packages/PyQt4/uic/init.py", line 213, in loadUiType
exec(code_string.getvalue(), ui_globals)
File "", line 44, in
File "/usr/lib64/python2.7/site-packages/qgis/utils.py", line 478, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: No module named QtWebKitWidgets.QWebView
Python version:
2.7.5 (default, Feb 11 2014, 07:46:25)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-13)]
QGIS version:
2.8.2-Wien Wien, exported
Python path: ['/usr/share/qgis/python/plugins/processing', '/usr/share/qgis/python', u'/home/qgisosr/.qgis2/python', u'/home/qgisosr/.qgis2/python/plugins', '/usr/share/qgis/python/plugins', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib64/python2.7/site-packages/wx-2.8-gtk2-unicode', '/usr/lib/python2.7/site-packages', u'/home/qgisosr/.qgis2//python', '/usr/share/qgis/python/plugins/fTools/tools', '/home/qgisosr/Downloads/Qgis-Plugin-Builder-master', '/usr/share/setroubleshoot/plugins']
While trying to edit the code generated in PyCharm IDE, it does not autocomplete from the iface
member of the plugin class.
That seems to be defined of type QgsInterface, which is not known by the IDE.
type: iface: QgsInterface
Not sure if is a problem of my environment but it seems that QgsInterface
is not available. There is QgisInterface
instead (note the i
of Qgis
prefix), so if I change the type definition to it, the autocompletion works as expected. Maybe it has changed name recently or is an alias my IDE is not aware of.
Some environment data:
Hi Gary,
building a plugin named 'SectorPlot', I end up with some code like this:
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'SectorPlot_{}.qm'.format(locale))
while when you run the scripts, the generated ts files are just names like nl.ts or af.ts, so you end up either rename those, or fix the code to:
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'{}.qm'.format(locale))
Another option would be to 'fix' the update-strings.sh and compile-strings.sh scripts to reflect the plugin-name-LOCALE.ts name. But I actually prefer to have the short names for the ts files with only the locale: like nl.ts etc etc
So what about fixing the code generator to NOT include the plugin name in the ts name?
(current setup is broken)
Hi friends,
I'll trying to create a plugin with the builder. This is the message at the end of the Wizard (when do you choose a directory to store the file).
Thanks. Emanuele.
++++++++
Traceback (most recent call last):
File "C:/Users/manu/.qgis2/python/plugins\pluginbuilder\plugin_builder.py", line 428, in run
self._prepare_code(specification)
File "C:/Users/manu/.qgis2/python/plugins\pluginbuilder\plugin_builder.py", line 170, in _prepare_code
specification, self.shared_dir, 'Makefile.tmpl', 'Makefile')
File "C:/Users/manu/.qgis2/python/plugins\pluginbuilder\plugin_builder.py", line 482, in populate_template
plugin_file = codecs.open(output_name_path, 'w', 'utf-8')
File "C:\PROGRA1\QGIS21.18\apps\Python27\lib\codecs.py", line 881, in open
file = builtin.open(filename, mode, buffering)
IOError: [Errno 2] No such file or directory: 'C:\Program Files\QGIS 2.18\e\Makefile'
Hi there!
Maybe it is a good idea to remove compiled python files in a 'make clean'?
This way we can easily clean the code before uploading to our repository.
I added the following line to my clean target and I thought that PluginBuilder could do the same:
"find -iname "*.pyc" -delete"
Thanks!
Tassia.
Base plugin class templates do not inherits from object
:
In python2 is a must, in python3 is recommendable due to readability (it's implicit).
The make deploy
rule fails with a vanilla generated processing plugin, because UI_FILES
and COMPILED_RESOURCE_FILES
is empty.
The corresponding cp
should be commented out I guess
This import doesn't work on QGIS weekly from PyQt5.QtGui import QAction, QIcon
It should by replaced by
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QAction
Hi !
Currently, a freshly built plugin causes an error because of missing resources.py
. It would be much more beginner-friendly if plugins worked out of the box by shipping a precompiled resources.py.
Thank you very much!
Olivier
Trying to show people who do not know too much about python to use the plugin builder AND look at naming conventions, I encounter the (tiny) problem that the class name (plugin name) is in the end used as package name. While using a short/lowercase name is more pythonic [0].
So, given most people (I think) will use the 'plugin name' as name for the module, what about using THAT as the package name (prepended with _plugin), so in case of current examples instead of using the Class name PhotoLinker as plugin-package name, we could use the module name (photo_linker) as package name (module_linker_package)?
Also given I personally have (and see other 'students') problems grasping the concept of plugin/package/module/class/algorithme/provider etc etc, if such naming conventions are not consequently used...
Happy to do a PR for this if others agree...
[0] https://www.python.org/dev/peps/pep-0008/#package-and-module-names
Plugin Builder is great.
But.. my fellow plugin builders, and myself, have some problems understanding the ui magic that is into a plugin that is build with the QGIS-plugin-builder.
After some diggin, I more or less understand that we do not build the ui anymore with pyuirc, but because of the FORM_CLASS lines it's get compiled runtime.
Because of this 'magic' people do not understand how to add a second dialog. Because just adding a ui file does not work. Another question I've been googling for: Why is the ui-file called *_base.ui and why does that not show up in class files (while if you do the pyuirc compile yourself, it will stay in the class file).
As most plugin builders are not very experienced Makefile users, the consise notation used in the Makefile like:
RESOURCE_SRC=$(shell grep '^ *<file' resources.qrc | sed 's@</file>@@g;s/.*>//g' | tr '\n' ' ')
%.py : %.qrc $(RESOURCES_SRC)
pyrcc4 -o $*.py $<
etc, make it pretty hard for Makefile newbies to 'just add' another ui/dialog or button/icon
Anyway: feature request: is it possible to add some documentation or text in the documentation about the workings of the FORM_CLASS magic, and maybe some steps on how to add a second dialog or button.
Thanks!
It gives an error saying OTB installation folder not found.
Not sure why we need OTB installation for a simple plugin creation.
Please advise.
These lines:
https://github.com/g-sherman/Qgis-Plugin-Builder/blob/master/plugin_template/module_name.tmpl#L174
https://github.com/g-sherman/Qgis-Plugin-Builder/blob/master/plugin_template/module_name.tmpl#L152
makes that the plugin is always added to the 'plugins' menu, thereby ignoring the value of 'category' in metadata.txt
(took me some time to figure out...)
The plugin builder should ship a logging system by default with a few lines how to use it for instance.
InaSAFE is using the logging
package to deal with QGIS, a remote server ...
https://github.com/inasafe/inasafe/blob/develop/safe/common/custom_logging.py
I am following this video: https://www.youtube.com/watch?v=DiwQ0SJYzJ8
My test suite fails when I run "make test":
isaac@ib:~/.qgis2/python/plugins/MakeOSMRoutableNetwork$ make test
----------------------------------------
Compiled translation files to .qm files.
----------------------------------------
----------------------
Regression Test Suite
----------------------
nose.plugins.cover: ERROR: Coverage not available: unable to import coverage module
#1 Test that the plugin __init__ will validate on plugins.qgis.org. ... ok
#2 Test we can click cancel. ... ok
#3 Test we can click OK. ... ok
#4 Test that QGIS properly parses a wkt string. ... FAIL
#5 QGIS environment has the expected providers ... FAIL
#6 Test we can click OK. ... ok
#7 Test that translations work. ... FAIL
======================================================================
FAIL: Test that QGIS properly parses a wkt string.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/isaac/.qgis2/python/plugins/MakeOSMRoutableNetwork/test/test_qgis_environment.py", line 50, in test_projection
self.assertEqual(auth_id, expected_auth_id)
AssertionError: u'' != 'EPSG:4326'
======================================================================
FAIL: QGIS environment has the expected providers
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/isaac/.qgis2/python/plugins/MakeOSMRoutableNetwork/test/test_qgis_environment.py", line 34, in test_qgis_environment
self.assertIn('gdal', r.providerList())
AssertionError: 'gdal' not found in []
======================================================================
FAIL: Test that translations work.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/isaac/.qgis2/python/plugins/MakeOSMRoutableNetwork/test/test_translations.py", line 49, in test_qgis_translations
self.assertEqual(real_message, expected_message)
AssertionError: u'Good morning' != 'Goeie more'
----------------------------------------------------------------------
Ran 7 tests in 0.015s
FAILED (failures=3)
----------------------
If you get a 'no module named qgis.core error, try sourcing
the helper script we have provided first then run make test.
e.g. source run-env-linux.sh <path to qgis install>; make test
----------------------
Before running it, I ran:
isaac@ib:~/.qgis2/python/plugins/MakeOSMRoutableNetwork$ source scripts/run-env-linux.sh /usr/bin/qgis
/usr/bin/qgis
QGIS PATH: /usr/bin/qgis
This script is intended to be sourced to set up your shell to
use a QGIS 2.0 built in /usr/bin/qgis
To use it do:
source scripts/run-env-linux.sh /your/optional/install/path
Then use the make file supplied here e.g. make guitest
This should be my qgis installation path, since I get this when running which qgis
:
isaac@ib:~/.qgis2/python/plugins/MakeOSMRoutableNetwork$ which qgis
/usr/bin/qgis
Any ideas? I cannot get the test suite to run in my IDE either (PyCharm)
I have no problem for a Dialog Plugin, but I need to fix some errors for a DockWidget Plugin (in addition to #65 )
In the main py script
replace:
# Initialize Qt resources from file resources.py
import resources
with:
# Initialize Qt resources from file resources.py
from .resources import *
and for the dockwidget import replace:
# Import the code for the DockWidget
from MyPlugin_dockwidget import MyPluginDockWidget
with:
# Import the code for the DockWidget
from .MyPlugin_dockwidget import MyPluginDockWidget
There is also a problem in the py script generate for the DockWidget
replace:
from PyQt5 import QtGui, uic
with:
from PyQt5 import QtGui, QtWidgets, uic
and replace:
class MyPluginDockWidget(QtGui.QDockWidget, FORM_CLASS):
with:
class MyPluginDockWidget(QtWidgets.QDockWidget, FORM_CLASS):
When indicating a folder to export the plugin files, if the folder is not selected properly, or if there is a root restriction on the selected folder, QGIS shuts down immediately without an error message.
in one of the dialog boxes for the plugin builder the user has to insert valid URLs for the Bug tracker, Repository, and Home page.
when I used the plug in for creating my project, I gave values which missed the http://
part, so what I inserted weren't valid URLs.
I suggest that the plugin builder warns about the mistake, or corrects it (possibly asking the user to check the changes).
see also this bug report
Builder currently creates a provider that tries to import:
from processing.core.AlgorithmProvider import AlgorithmProvider
Instead, working Processing provider plugins for QGIS 3 import:
from qgis.core import QgsProcessingProvider
This is just the first of many things that need to be updated.
Had problems setting up translation with this plugin.
In generated "plugin_name.py" the row:
'plugin_name{}.qm'.format(locale))_
needs to be changet to just:
'{}.qm'.format(locale))
Then everything works just fine!
I'm not sure about it, but with the upcoming QGIS 3 the QGISDIR
is not .qgis3
anymore, but it depends on user profiles. Shouldn't also the variable here:
be changed?
When generating new dialog or dock widget plugins using Plugin Builder, the results/readme texts are generating incorrect file names when giving instruction on modifying the user interface in QT Designer.
Create dialog plugin named test1
Both README.txt and README.html files to display the line:
Modify your user interface by opening test1_dialog_base.ui in Qt Designer
README.txt shows (incorrect file name: Test1.ui
):
* Modify your user interface by opening Test1.ui in Qt Designer
Create dock widget plugin named test2
Both README.txt and README.html files to display the line:
Modify your user interface by opening test2_dockwidget_base.ui in Qt Designer
Results pop-up/README.html shows (incorrect file name: test2_dialog_base.ui
):
Modify your user interface by opening test2_dialog_base.ui in Qt Designer
README.txt shows (incorrect file name: test2.ui
):
* Modify your user interface by opening test2.ui in Qt Designer
Running make test results in:
$ make test
pyrcc4 -o resources_rc.py resources.qrc
----------------------------------------
Compiled translation files to .qm files.
----------------------------------------
safe_qgis/i18n/inasafe_af.ts
scripts/compile-strings.sh: line 9: lrelease-qt4: command not found
make: *** [transcompile] Error 127
There are two issues with this. Presumably the reference to insafe shouldn't be there. Secondly, on my machine I don't have lrelease-qt4 - the binary is just called lrelease.
Just built QGIS 2.6 and installed the plugin (version 2.6.0) from the repository. Upon launching the plugin, I get the following error:
An error has occured while executing Python code:
Traceback (most recent call last):
File "/home/nfrazier/.qgis2/python/plugins/pluginbuilder/plugin_builder.py", line 378, in run
self.dialog.setWindowTitle('QGIS Plugin Builder - {}'.format(version))
ValueError: zero length field name in format
Python version:
2.6.6 (r266:84292, Nov 21 2013, 12:39:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]
QGIS version:
2.6.0-Brighton Brighton, exported
Python path: ['/usr/local/share/qgis/python', u'/home/nfrazier/.qgis2/python', u'/home/nfrazier/.qgis2/python/plugins', '/usr/local/share/qgis/python/plugins', '/usr/lib64/python2.6/site-packages/distribute-0.6.19-py2.6.egg', '/usr/lib64/python2.6/site-packages/pyopencl-2012.1-py2.6-linux-x86_64.egg', '/usr/lib64/python2.6/site-packages/decorator-3.4.0-py2.6.egg', '/usr/lib64/python2.6/site-packages/pytest-2.3.4-py2.6.egg', '/usr/lib64/python2.6/site-packages/pytools-2012.1-py2.6.egg', '/usr/lib64/python2.6/site-packages/py-1.4.13-py2.6.egg', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib64/python2.6/site-packages/gst-0.10', '/usr/lib64/python2.6/site-packages/gtk-2.0', '/usr/lib64/python2.6/site-packages/webkit-1.0', '/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode', '/usr/lib/python2.6/site-packages', '/usr/local/share/qgis/python/plugins/fTools/tools']
As described here a plugin can't find the resource_rc.py
file when a file is referenced in the in the plugin's ui file.
Just installed Plugin builder (3.0.3) on my Windows machine (with QGIS 3.2.1-1) and when I tried to select Tags for my plugin nothing happend (I wrote some my self) and continued, later I saw the error message FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/USERNAME/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\pluginbuilder3\taglist.txt' Might be missing from the latest plugin upload?
Hi !
Under Windows 8, QGIS 2.8.1, 64bits, I get this error message upon installation :
This plugin is broken No module named win32api
Thanks !
I have a question about the further development. If I wanna add two functions (with two different UI) into the save sub-menu, how can I do it? I add several functions via add_action(), like :
self.add_action(
icon_openprj,
text=self.tr(u'Open Project'),
callback=self.run_open,
parent=self.iface.mainWindow())
which can create multiple functions in the menu and toolbar. But the problem is how to handle the UI and working functions for them? Any tutorials?
Thank you.
Hi,
I am trying to create a plugin with the Plugin Builder 2.10.1. When unselecting the Help option in the Additional Components Section I get the following error:
An error has occured while executing Python code:
Traceback (most recent call last):
File "/home/benjamin/.qgis2/python/plugins/pluginbuilder/plugin_builder.py", line 432, in run
self._prepare_tests(specification)
File "/home/benjamin/.qgis2/python/plugins/pluginbuilder/plugin_builder.py", line 118, in _prepare_tests
'help/source/conf.py.tmpl', 'help/source/conf.py')
File "/home/benjamin/.qgis2/python/plugins/pluginbuilder/plugin_builder.py", line 481, in populate_template
plugin_file = codecs.open(output_name_path, 'w', 'utf-8')
File "/usr/lib/python2.7/codecs.py", line 878, in open
file = builtin.open(filename, mode, buffering)
IOError: [Errno 2] No such file or directory: '/home/benjamin/Documents/QG/test/help/source/conf.py'
Python version:
2.7.6 (default, Jun 22 2015, 18:01:27)
[GCC 4.8.2]
QGIS version:
2.8.1-Wien Wien, exported
Python path: ['/usr/share/qgis/python/plugins/processing', '/usr/share/qgis/python', u'/home/benjamin/.qgis2/python', u'/home/benjamin/.qgis2/python/plugins', '/usr/share/qgis/python/plugins', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', u'/home/benjamin/.qgis2//python', '/usr/share/qgis/python/plugins/fTools/tools', '.']
there's users around who don't read instructions, or do so only when everything else fails. what about giving some hint when they run make
? as of now, they only get a disappointing make: Nothing to be done for 'default'.
I would suggest either @echo please read the docs at http://geoapt.net/pluginbuilder/
, or adding a list
target as described on this Q&A on stackoverflow.
In the bash file there is a line:
print ${PYTHON_FILES}
What's this supposed to do? On my system it starts runmailcap. I can't see the point of that. It just gives the following errors:
------------------------------------------------
Updating translation files with any new strings.
------------------------------------------------
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/%{ <-- HERE (.*?)}/ at /usr/bin/print line 528.
Error: no "print" mailcap rules found for type "text/x-python"
Error: no "print" mailcap rules found for type "text/x-python"
Error: no "print" mailcap rules found for type "text/x-python"
Error: no "print" mailcap rules found for type "text/x-python"
Error: no "print" mailcap rules found for type "text/x-python"
Error: no "print" mailcap rules found for type "text/x-python"
Error: no "print" mailcap rules found for type "text/x-python"
Error: no "print" mailcap rules found for type "text/x-python"
Error: no "print" mailcap rules found for type "text/x-python"
Error: no "print" mailcap rules found for type "text/x-python"
Error: no "print" mailcap rules found for type "text/x-python"
Error: no "print" mailcap rules found for type "text/x-python"
Error: no "print" mailcap rules found for type "text/x-python"
Error: no "print" mailcap rules found for type "text/x-python"
Error: no "print" mailcap rules found for type "application/xml"
Please provide translations by editing the translation files below
Removing the line solves the issue. On my system (Ubuntu) print is an alias for run-mailcap.
I found this very helpful in seeing how to start adapting a QGIS 2.n plugin for QGIS 3.
Two typos in the Makefile:
Some of my .ui files refer to a resources.qrc file. This caused the plugin to fail to load. I eventually managed to fix this (I hope!) by changing the FORM_CLASS definition in the dialog.py file to
pdir = os.path.dirname(__file__)
FORM_CLASS, _ = uic.loadUiType(os.path.join(pdir, 'QSWAT_dialog_base.ui'),
from_imports=True,
resource_suffix='',
import_from=os.path.basename(pdir))
when giving make package
and you don't specify the VERSION
parameter, you get an error report from git, which is to be expected and is not particularly informative. better catch the error beforehand, and stop. this way the output is a lot more terse and easy to understand to a distracted and hurried person.
mario@rune:~/Local/github/Ghini/DistanceMatrixToCoords$ make package
# Create a zip package of the plugin named DistanceMatrixToCoords.zip.
# This requires use of git (your plugin development directory must be a
# git repository).
# To use, pass a valid commit or tag as follows:
# make package VERSION=Version_0.3.2
try again, this time specifying the target VERSION
mario@rune:~/Local/github/Ghini/DistanceMatrixToCoords$
diff --git a/Makefile b/Makefile
index 147691c..389a63b 100644
--- a/Makefile
+++ b/Makefile
@@ -155,6 +155,9 @@ package: compile
# git repository).
# To use, pass a valid commit or tag as follows:
# make package VERSION=Version_0.3.2
+ifeq (k$(VERSION),k)
+ @echo try again, this time specifying the target VERSION
+else
@echo
@echo "------------------------------------"
@echo "Exporting plugin to zip package. "
@@ -162,6 +165,7 @@ package: compile
rm -f $(PLUGINNAME).zip
git archive --prefix=$(PLUGINNAME)/ -o $(PLUGINNAME).zip $(VERSION)
echo "Created package: $(PLUGINNAME).zip"
+endif
upload: zip
@echo
Good morning,
I am a student and i want to develop a plugin, I want to try your plugin in Qgis 2.8.3 but I have a message error tell me invalid syntax.
Everytime I setup a new plugin with plugin builder I have to manually add a
del self.toolbar
at the end of unload function to correctly remove the plugin toolbar when I reload or unload it.
Is it possible to add it by default?
Thanks.
maybe more a question than a request, but I wish to add a second dialog box (to be activated by a second menu entry) to my single plugin, and I wondered if this QGIS plugin builder would be able to assist me.
I can't remember being asked the question "your plugin has multiple menu entries/dialog boxes?"
Hi !
QGIS 3.3
Plugin Builder 3.0.3
It seems the plugin are created in a directory using the lowercase class name in the output directory.
On the select output directory page, it's written :
You plugin will be created in the selected location, using the module name for the name of the subdirectory
When I manually change the output directory, this is further confirmed by showing the full path :
C:/my/path\module_name
But when I hit save, it's saved under
C:\my\path\classname
This can be very bad as you can completely mess up existing plugins inadvertently.
By the way : the full path should be refreshed when the page is shown, as it's not shown initially, and is wrong if the user goes back to change the module_name.
Thanks !!
Generated a QGIS3 plugin and am seeing a number of test failures due to failure to migrate from QGIS2 to QGIS3 API in the unit tests. I'll document a few of them here as I work through them.
from qgis.core import QgsMapLayerRegistry
should now be from qgis.core import QgsProject
and QgsMapLayerRegistry should be replaced with QgsProject in qgis_interface.pyfrom qgis.gui import QgsMapCanvasLayer
in qgis_interface.py: this module no longer exists. I haven't groked the code enough yet to understand what to replace this with; it seems like probably a look over the layers returned by selectedLayers = QgsProject.instance().layerTreeRoot().selectedLayers()
.Maybe it is just me, but I'm used to hitting escape, when for example I think I made and error in a class name and want to see the default example again.
Also when writing to files, hitting the escape button closes all dialogs and forgets everything.
Now I cut myself just 1 time too often, so thought to make an issue of it...
So in short: would it be possible to have a confirmation in between the closing of the wizard OR have a possiblity to 'remember' earlier input?
In pb_tool.cfg there is a link which does not work:
http://spatialgalaxy.net/qgis-plugin-development-with-pb_tool
In Makefile used variable COMPILED_UI_FILES ( https://github.com/g-sherman/Qgis-Plugin-Builder/blob/master/plugin_template/Makefile.tmpl#L193 )
Where is it get value?
Why "deploy" instructions on line https://github.com/g-sherman/Qgis-Plugin-Builder/blob/master/plugin_template/Makefile.tmpl#L110 use UI_FILES variable but not COMPILED_UI_FILES ?
Where is .ui files convert to .py file?
I recently noticed that as a default behavior when one generates a plugin using Plugin Builder, the default dialog created will be instantiated right away as it is put in the init of the main class and called by the classFactory.
This classFactory is called when starting QGIS. So, the more users have python plugins, the longer QGIS will start up. For some developers maybe they will notice this and restructure their plugins built from Plugin Builder.
I am wondering if it would be better if we should keep it simple in the init of the main class (don't instantiate main dialog as well) and just instantiate the dialog in the action.
The instructions in the generated README.txt and README.html contain the following:
" * Compile the resources file using pyrcc4"
It should say:
" * Compile the resources file using pyrcc5"
Here is one place where the text originates:
Qgis-Plugin-Builder/plugin_templates/toolbutton_with_dialog/template/readme.tmpl
Hi,
The compile-strings.sh and update-strings.sh files in the scripts folder deal with a file that should be i18n/$LOCALE.ts . Then, executing the makefile, the user creates a .qm file named i18n/$LOCALE.qm.
But the main class of the plugin (in plugin_name.py > init.py ) is awaiting for a .qm file whose name is like i18n/plugin_name_$LOCALE.ts .
QGIS then doesn't recognized this .qm file when enabling the plugin.
The dlg.setupUi()
is called too early, i.e. in the __init__
of the main template class. The plugin GUI should be populated on plugin startup, not QGIS startup (I think), which compromises QGIS performance. I.e. it should be called in def run(self)
.
Addressed in #93.
This problem occurs when loading QGIS and a plugin is being restored.
uic
cannot find resources_rc.py
A complete description of the symptoms can be seen in my answer on gis.stackexhange.
This problem occurs after the resources of a plugin are edited in QtDesigner.
In the .ui file is a resources tag, <resources/>
.
After editing the plugin resources, the .ui
file has
<resources>
<include location="resources.qrc"/>>
</resources>
The plugin_dialog.py file has a line
FORM_CLASS, _ = uic.loadUiType(os.path.join(os.path.dirname(__file__), 'test_dialog_base.ui'))
This is the call which generates the error as uic
cannot find the file resources_rc.py which it is trying to include.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.