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 fTools
module 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
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.