Graphics Reference
In-Depth Information
• You can display a list of previously-entered commands by pressing Ctrl + Shift +
Space ( command + Shift + Space on Mac).
• If you select some text in the Interpreter Log, you can use the Enter Selected
command to move that text to the shell and execute it. This command is available
in the console's pop-up menu, or it can be accessed by pressing Ctrl + E ( com-
mand + E if you are running Mac OS X).
• The Python Shell supports auto-completion . As you type, a pop-up menu ap-
pears, showing you the matching class, function, and method names within the
PyQGIS and PyQt APIs. You can then press the up and down arrow keys to select
the exact name you want, and press the Tab key to select it.
• When you type an opening parenthesis, the console automatically enters the clos-
ing parenthesis for you. You can turn this off by using the Settings window if you
wish.
• When you type from XXX , the console enters the word import for you auto-
matically. Once again, you can turn this off in the Settings window if you don't
like this behavior.
• When you type the opening parenthesis for a function or method, the C++ signa-
ture for that function or method will be displayed. Despite being in C++ format,
this tells you which parameters are expected and the type of value being returned.
• You can type _api into the shell; your web browser will open the PyQGIS API
reference documentation. Similarly, if you type _pyqgis , your web browser will
display the PyQGIS Developer Cookbook.
While typing commands into the Python Shell is a useful way of exploring the QGIS
Python libraries, and is good for one-off commands, it quickly gets tedious if you have to
type multiple lines of Python text or repeat the same set of commands over and over. After
all, this is why we store Python code in .py files and execute them, rather than just typ-
ing everything into the Python command-line interface.
The QGIS Console comes with its own editor, allowing you to write Python scripts and
execute them directly within the console. Let's take a quick look at how this works.
With the QGIS Console open, click on the Show Editor icon ( ). The console win-
dow will be split in half, with the Python source code editor now taking up the right-hand
side of the window:
Search WWH ::




Custom Search