1

I can open the console programmatically, using:

qgis.utils.iface.actionShowPythonDialog().trigger()

Is there a way to additionally open the console's editor (the window where you can enter multiple lines of code)?

1
2

You need find the widget and after the QAction,It doesn't have a direct method in PyQGIS

consoleWidget = iface.mainWindow().findChild( QDockWidget, 'PythonConsole' )
consoleWidget.console.showEditorButton.trigger()

To find the name of the objects look at the source code

https://github.com/qgis/QGIS/blob/cce5c4e80265a7797c2b9fb9219ccad0238b6d04/python/console/console.py#L300

Or, this other way , based on this answer https://gis.stackexchange.com/a/358580/49538

from console import console
console._console.console.showEditorButton.trigger()
1
  • 1
    Both work, amazing! Cool how you can trigger a click on that button, wasn't aware of that. – BritishSteel May 4 '20 at 8:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.