Hi (again) ! I figured out (after 2 days of research !) that in a standalone app, to be able to open a custom layer form when identifying a feature, I have to implement a specific QgsPythonRunner child class (code below). And then I have to set the QgsPythonRunner.
The problem is that I can't get evalCommand() to work because the variable result is a C++ reference, and python can't deal with it, can it ? Maybe there is a workaround I didn't think through, or there is a need to pass result as a return value ? Thanks ! BR class PythonRunnerStandalone(QgsPythonRunner): def __init__(self): super().__init__() def runCommand(self, command, messageOnError): try: exec(command, globals()) return True except Exception as e: if messageOnError == "": print("Error with command:\n") else: print(messageOnError + "\n") print(command) print("Catched exception:\n", e) return False def evalCommand(self, command, result): try: result = eval(command) # problem here return True except Exception as e: print("Error with command:\n") print(command) print("Catched exception:\n", e) return False qgis.core.QgsPythonRunner.setInstance(PythonRunnerStandalone()) In QGIS source code qgis-latest/qgis-3.8.2/src/gui/qgsattributeform.cpp lines 1610-1625: QString numArgs; // Check for eval result if ( QgsPythonRunner::eval( QStringLiteral( "len(inspect.getargspec(%1)[0])" ).arg( initFunction ), numArgs ) ) // Here numArgs is passed as reference to my python implementation [...] if ( numArgs == QLatin1String( "3" ) ) // always fails here Jacky Volpes HR Team pour la Société du Canal de Provence | 2SI - QGIS Le Tholonet, CS70064 jacky.volpes-...@canal-de-provence.com<mailto:jacky.volpes-...@canal-de-provence.com>
_______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer