Interactive console

Whether you use MS Windows or Linux, you should have QGIS installed with Python console. We will use it now to determine system version.

Go to Plugins ‣ Python console (Ctrl+Alt+P). This should open a new window with an interactive console.

../_images/console.png

Fig. 1 Interactive Python console in QGIS.

After you open Python console, you should see these buttons:

clearConsole

Clear window contents and delete all displayed text

runConsole

Run command. You can use this button or just simply press Enter

showEditorConsole

Opens a text editor. You can edit your code through it

settingsConsole

Advanced settings of console and editor

helpConsole

This will launch web browser with help manual

Python console gives us option to write code more interactively. Moreover the console supports syntax highlight. You can also save your code to a file. When you press Ctrl-Alt-Space, it will automatically insert commands. To see history of commands, press Ctrl-Shift-Space.

Let’s start with a command:

>>> _pyqgis

which display documentation for Python in QGIS as a new tab in web browser.

Similarly

>>> _api

will also display C++ API documentation.

Editor

Built-in code editor can be open by clicking on icon showEditorConsole. Automatic prompting (Ctrl+Space) can be very useful while writing a code. To check code syntax, press (Ctrl+4). Another useful functions are search in code and inspect the code.

../_images/editor.png

Fig. 2 Built-in Python code editor.