2

I have written a PyQGIS processing script that can be used from Toolbox. I would like to convert this to plugin and publish. The script is taking input and output from the user through processing algorithm built-in parameter Ccasses.

enter image description here

If I convert this to plugin using the Plugin Builder 3 plugin. Will it generate the same user interface? If not what is the right way of converting a toolbox script to plugin?

1 Answer 1

4

You can create a skeleton for processing plugin from the "QGIS plugin builder".

You should more or less use the instructions from this tutorial https://www.qgistutorials.com/sl/docs/3/processing_python_plugin.html You will need to adapt them due to your own plugin particularities.

By default, the generated plugin does not contain the help part (right content) but by adding in your own plugin the method shortHelpString, it works fine (see the ScriptTemplate.py file from the QGIS repo for an ilustration). See below screen capture as a proof :)

capture plugin with processing algorithm

4
  • Thank you. It looks like this is pretty much all that I need. Do you know if we can tweak the interface as well if we use this approach? For example, I would like to group all my output parameters under the heading of Output Parameters and put them at the bottom? Jun 3, 2020 at 13:25
  • 1
    Not to my knowledge, no GUI reference in the plugin itself (so I don't see how you could tweak). GUI generated by the config from the provider and internal to QGIS (if not, I'm not aware)
    – ThomasG77
    Jun 3, 2020 at 14:01
  • 1
    Do you know If I have some layer styles files and a table file referenced in my script, how can I publish along that embedded with the plugin so that plugin can work at any machine? Currently, the files are at my C drive and are referenced by the script. Jun 5, 2020 at 3:09
  • 1
    Search string self.plugin_dir and locale_path = in your generated plugin files for an example (relative path already used for locale e.g translation)
    – ThomasG77
    Jun 5, 2020 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.