November 2018
Beginner to intermediate
272 pages
5h 36m
English
At the top of the my_first_plugin.py script, add QMessagebox to the imports. This is shown in the following code:
from PyQt5.QtWidgets import QApplication, QAction, QWidget, QPushButton, QMessageBox
Now add the following two lines of code to the bottom of the run method. Make sure they are within the if statement.
msgbox = QMessageBox(QMessageBox.Information, "How many layers?", "Number of features in layer: %s" % layer.featureCount(), QMessageBox.Ok)msgbox.exec_()
Save and reload your plugin in QGIS. You will find that after clicking OK, the number of layers in the layer selected in the drop-down box will appear as an information box. This is shown in the following screenshot:
Read now
Unlock full access