Python Console for QGIS

Console
Editor
Settings

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.
The console is split in two main panes, top and bottom one resizable by using the horizontal splitter. Output area pane is a widget read-only which shows the commands output. You can drag and drop or copy and paste text into input area and execute code snippets from the output pane by selecting some text and clicking on the command from the context menu. No matter if selected text contains the interpreter prompt (>>>, ...). Input area pane is the interactive python shell for input commands.
To access to the python file editor use the button from the toolbar. The editor allows to edit and save python file and it offers basic functionality for managing your code (comment and uncomment code, check syntax, share the code via codepad.org and much more).

Console

Main features:
  • Code completion, highlighting syntax and calltips for the following APIs:
    1. Python
    2. PyQGIS
    3. PyQt4
    4. QScintilla2
    5. osgeo-gdal-ogr

  • to view the auto-completion list.

  • to view the command history list.

  • Execute code snippets with the command from output pane.

  • Open QGIS API documentation by typing .

  • Open PyQGIS Cookbook by typing .

  • Save and clear the command history accessing from context menu of input pane. The history will be saved into the file ~/.qgis2/console_history.txt

Toolbar:
Clear python console
Import Processing class
Import PyQt4.QtCore class
Tool to import PyQt4.QtGui class
Run command (like Enter key pressed)
Settings
Help

Editor

Main features:
  • Code completion, highlighting syntax and calltips for the following APIs:
    1. Python
    2. PyQGIS
    3. PyQt4
    4. QScintilla2
    5. osgeo-gdal-ogr

  • to view the auto-completion list.

  • Sharing code snippets via codepad.org.

  • Syntax check.

  • Object inspector: a class and function browser.

  • Go to an object definition with a mouse click. (from Object inspector)

  • Execute code snippets with the command.

  • Execute the whole script with the command (this creates a byte-compiled file with the extension .pyc)

Settings

Further settings for python console:

Note: 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.