Is there any way to detect if a script is computed on QGIS python console or not?
Any attribute or test to assess it?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityIs there any way to detect if a script is computed on QGIS python console or not?
Any attribute or test to assess it?
You sure can.
import qgis.utils
inqgis = qgis.utils.iface is not None
In QGIS this will return True
outside it will return False
I didn't check, try this:
A) from qgis.utils import iface
B) iface.mainWindow() == None
giev us a feedbak