6

I am trying to launch the UI of a processing algorithm using Python script but I cannot find a simple way for it (aside double clicking on it in the process toolbox of course). The plugin is a water network simulator and I just want to launch its pre-processing UI without using process.runalg() because this needs to enter arguments and I don't need it.

Some ways would be to trigger processes available in process toolbox or sending command to commander from python console. but I have no clue how and I am searching for 2 hours now, no results.

  • 1
    Hi, thanks again for the answer.. Although I was doing PyQGIS exclusively for my thesis so I passed this stage and didn't have it anymore until now I tested it in some other PCs. but thanks any ways :) – user2725916 Jan 24 '16 at 17:35
9

You can do that from the QGIS Python console in this way:

# Import both Processing and CommanderWindow 
#   classes from the Processing framework. 
from processing.core.Processing import Processing
from processing.gui.CommanderWindow import CommanderWindow

# Then get the algorithm you're interested in (for instance, Join Attributes):
alg = Processing.getAlgorithm("qgis:joinattributestable")

# Instantiate the commander window and open the algorithm's interface 
cw = CommanderWindow(iface.mainWindow(), iface.mapCanvas())
if alg is not None:
    cw.runAlgorithm(alg)

That's it! You get the algorithm's UI open.

enter image description here

Note: You can get the names of the available algorithms by entering these lines in the QGIS Python console:

import processing
processing.alglist()

Tested in QGIS 2.10.1, Processing framework v.2.9.1 and v.2.10.1


EDIT:

If you find errors when running the code snippet above, chances are you're using QGIS v2.16.0, v2.16.1, or v2.16.2. To solve the issue, install QGIS v2.16.3.

  • 1
    tested also for the upcoming QGIS3, thanks! – matteo Mar 14 '17 at 15:31
  • Hmm, in QGIS 3.4.1 I can't import CommanderWindow.. Any idea how to fire up a Processing GUI in the current API? – nnolde Dec 24 '18 at 21:43

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.