Comment by smitty1e

12 hours ago

This point came home recently in doing a little macro to load a directory of GeoJSON documents into QGIS.

You need to load the Python console to get the proper environment, and you can't just say logger.debug() to get a trace.

This is because QGIS runs in the Qt event loop.

Big cluebat: QGIS (qualitatively, and for the regular pythonista) is like doing everything via asyncio.

Ah, so: no wonder it's such a challenge.

Yeah, though I would probably paint this as a case where the logic of the application is very tied up the UI, which makes it generally quite difficult to access the functionality as a library (or e.g. from the command line). Some applications have things seperated out enough, but this is usually something you need to start with as a goal. Other applications do have a scripting interface which you can use to automate things, and this can work quite well, but sometimes it is still very tied to the UI (e.g. blender, where it is quite powerful but you are essentially still driving the UI from the commands instead of describing the actions you want. e.g. you need to change modes in order to perform certain actions).