` `
As you will see later in this chapter, QGIS has been designed with a plugin architecture. Plugins can be written in Python, a very famous language in the geospatial world.
QGIS brings a Python API (see PyQGIS Developer Cookbook for some code sample) to let the user interact with its objects (layers, feature or interface). QGIS also has a Python console.
The QGIS Python Console is an interactive shell for the python command executions. It also has a python file editor that allows you to edit and save your python scripts. Both console and editor are based on PyQScintilla2 package. To open the console go to Plugins ‣ Python Console (Ctrl+Alt+P).
Consola interactivă este alcătuită dintr-o bară de instrumente, o zonă de intrare și una de ieșire.
Bara instrumentelor propune următoarele instrumente:
The console main features are:
Tip
Reuse executed commands from the output panel
You can execute code snippets from the output panel by selecting some text and pressing Ctrl+E. No matter if selected text contains the interpreter prompt (>>>, ...).
Use the Show editor button to enable the editor widget. It allows editing and saving Python files and offers advanced functionalities to manage your code (comment and uncomment code, check syntax, share the code via codepad.org and much more). Main features are:
Ctrl+4 Verificare sintaxă.
Note
Running partially or totally a script from the Code Editor outputs the result in the Console output area.
Accessible either from the Console toolbar or the contextual menu of Console output panel or Code Editor, this adds further settings to manage and control the Python console behavior:
Tip
Save the options
To save the state of console’s widgets you have to close the Python Console from the close button. This allows you to save the geometry to be restored to the next start.