1

After having built a QGIS 3 plugin, I'd like to know how could I call my plugin without clicking on the plugin bar of QGIS to launch it.

I've tried implement a first batch file for it :

REM changer OSGEO4W_ROOT pour aller sur le dossier du shell
SET OSGEO4W_ROOT=C:\Program Files\QGIS 3.4
SET QGISNAME=qgis
SET QGIS=%OSGEO4W_ROOT%\apps\%QGISNAME%
SET QGIS_PREFIX_PATH=%QGIS%
REM Gdal setup
SET PATH=%OSGEO4W_ROOT%\bin;%QGIS%\bin;%PATH%
SET PYTHONHOME=%OSGEO4W_ROOT%\apps\Python37
SET PYTHONPATH=%QGIS%\python;%PYTHONPATH%

REM Launch python
REM python "C:\Users\(username)\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\tombarel\zoom_snap_dialog.py"
pause

The problem is I don't know how to launch the plugin from my batchfile once I've opened QGIS (version 3.4.4)

I've seen previous answers where fToolsmodule was still available for QGIS 2.X. but about the version 3 of QGIS I can't figure out how to do a standalone program which actions the plugin

I've tried to look at the run()method in the plugin main python file but I couldn't find a way either to call it from another python file

  • So, you want your plugin to automatically start once you open a QGIS-project? – Erik Feb 8 at 14:30
  • Yes, once QGIS opened and the project loaded, I'd like a program (out of QGIS) to send a signal to QGIS to start and open the plugin – Brocolus Feb 8 at 14:40
  • 2
    search for startup.py which is automatically run by qgis at startup and call your plugin in this script. – snaileater Feb 8 at 18:39
  • 2
    If you want to autostart your plugin once QGIS is started startup.py is the best way to go. Otherwise if you want to start it while QGIS is running from another application you need a mechanism to send and receive data between different processes. I would use startup.py to start a TCP socket server in a separate thread listening for incoming connections. From anywhere else a client may connect and send some data. If the server recognizes this data, it gets reference to QGIS instance and triggers some action associated with this kind of data. – Detlev Feb 9 at 7:54
  • 1
    This question is about a similar problem. gis.stackexchange.com/q/287057/46073 – Andreas Müller Feb 10 at 22:11

Your Answer

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

Browse other questions tagged or ask your own question.