QGIS-Using the python console

As previously said, the QGIS python console is a good way to test step by step your code before implementing it to your plugin…

To access the python console, just go to plugins > python console.

Notice the example instruction in the shell iface.zoomFull(): this command is applied on the interface object called iface. It performs a zoom that makes all your objects visible.
Just try typing it in the shell to see the result:

The QGIS console is similar to a python shell but there are some limitations like the impossibility of writing multiples lines of code in one time,as it is possible with the usual python shell.

Usually, the “for” and “while” statements require multiples lines. They are often used to get lists. As the “for” and “while” statements are unavalaible, you’ll have to deal with the notion of list comprehension to get a list of values.
Look at these links to learn how to use them:
In the examples i’ll show you in the next posts, you’ll see some examples of these notions.

You can also have to use map, filter, and reduce functions, that are used on lists:

To write functions, you’ll have to get familiar with lambda function…

Une réflexion sur « QGIS-Using the python console »

  1. I would like to see more how to use the python console. Any example python script that do geo processing joining table with shapefile table. Noli

Répondre à Noli Annuler la réponse

Votre adresse e-mail ne sera pas publiée.

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.