November 2018
Beginner to intermediate
272 pages
5h 36m
English
The layer combo box is empty and we want to add layers to it. To achieve this, we need to add a few lines of code to my_first_plugin.py (located in the plugin folder). Firstly, make sure all the imports are correct:
from PyQt5.QtCore import QSettings, QTranslator, qVersion, QCoreApplicationfrom PyQt5.QtGui import QIconfrom PyQt5.QtWidgets import QActionfrom qgis.core import *# Initialize Qt resources from file resources.pyfrom .resources import *# Import the code for the dialogfrom .my_first_plugin_dialog import MyFirstPluginDialogimport os.path
Then change the run() method:
def run(self): """Run method that performs all the real work""" # show the dialog self.dlg.show() # clear the combo box self.dlg.layerCombo.clear() ...
Read now
Unlock full access