AuthorUjaval Gandhi Follow @spatialthoughts Change Language English Download PDF [A4] (../pdf/building_a_python_plugin_a4.pdf) [Letter] (../pdf/building_a_python_plugin_letter.pdf) Share Building a Python Plugin Plugins are a great way to extend the functionality of QGIS. You can write plugins using Python that can range from adding a simple button to sohpisticated toolkits. This tutorial will outline the process involved in setting up your development environment, designing the user interface for a plugin and writing code to interact with QGIS. Please review the Getting Started With Python Programming (getting_started_with_pyqgis.html) tutorial to get familiar with the basics. Overview of the Task We will develop a simple plugin called Save Attributes that will allow users to pick a vector layer and write its attributes to a CSV le. Get the Tools Qt Creator Qt (http://www.qt.io/) is a software development framework that is used to develop applications that run on Windows, Mac, Linux as well as various mobile operating systems. QGIS itself is written using the Qt framework. For plugin development, we will use an application called Qt Creator (http://doc.qt.io/qtcreator/index.html) to design the interface for our plugin. Download and install the Qt Creator software from SourgeForge (http://sourceforge.net/projects/qtcreator.mirror/ les/latest/download) Python Bindings for Qt Since we are developing the plugin in Python, we need to install the python bindings for Qt. The method for installing these will depend on the platform you are using. For building plugins we need the pyrcc4 command-line tool. Windows Download the OSGeo4W network installer (http://trac.osgeo.org/osgeo4w/) and choose Express Desktop Install. Install the package QGIS . After installation, you will be able to access the pyrcc4 tool via the OSGeo4W Shell. Mac Install the Homebrew (http://brew.sh) package manager. Install PyQt package by running the following command: brew install pyqt Linux Depending on your distribution, nd and install the python-qt4 package. On Ubuntu and Debian-based distributions, you can run the following command: sudo apt-get install python-qt4 A Text Editor or a Python IDE Any kind of software development requires a good text editor. If you already have a favorite text editor or an IDE (Integrated Development Environment), you may use it for this tutorial. Otherwise, each platform o ers a wide variety of free or paid options for text editors. Choose the one that ts your needs. This tutorial uses Notepad++ editor on Windows. Windows Notepad++ (http://notepad-plus-plus.org/) is a good free editor for windows. Download and install the Notepad++ editor (http://notepad-plus- plus.org/repository/6.x/6.7.5/npp.6.7.5.Installer.exe). Note If you are using Notepad++, makes sure to check Replace by space at Settings ‣ Preferences ‣ Tab Settings. Python is very sensitive about whitespace and this setting will ensure tabs and spaces are treated properly. Plugin Builder plugin There is a helpful QGIS plugin named Plugin Builder which creates all the necessary les and the boilerplate code for a plugin. Find and install the Plugin Builder plugin. See Using Plugins (using_plugins.html) for more details on how to install plugins. Plugins Reloader plugin This is another helper plugin which allows iterative development of plugins. Using this plugin, you can change your plugin code and have it re ected in QGIS without having to restart QGIS every time. Find and install the Plugin Reloader plugin. See Using Plugins (using_plugins.html) for more details on how to install plugins. Note Plugin Reloader is an experimental plugin. Make sure you have checked Show also experimental plugins in Plugin Manager settings if you cannot nd it. Procedure 1. Open QGIS. Go to Plugins ‣ Plugin Builder ‣ Plugin Builder. 2. You will see the QGIS Plugin Builder dialog with a form. You can ll the form with details relating to our plugin. The Class name will be the name of the Python Class containing the logic of the plugin. This will also be the name of the folder containing all the plugin les. Enter SaveAttributes as the class name. The Plugin name is the name under which your plugin will appear in the Plugin Manager. Enter the name as Save Attributes . Add a description in the Description eld. The Module name will be the name of the main python le for the plugin. Enter it as save_attributes . Leave the version numbers as they are. The Text for menu item value will be how the users will nd your plugin in QGIS menu. Enter it as Save Attributes as CSV . Enter your name and email address in the appropriate elds. The Menu eld will decide where your plugin item is added in QGIS. Since our plugin is for vector data, select Vector . Check the Flag the plugin as experimental box at the bottom. Click OK. qgis2/ directory is located in your home directory. The plugin folder location will depend on your platform as follows: (Replace username with your login name) Windows c:\Users\username\. Typically. . 3.qgis2/python/plugins Linux /home/username/. You need to browse to the QGIS python plugin directory on your computer and select Select Folder. a .qgis2\python\plugins Mac /Users/username/. Note the path to the plugin folder. Next.qgis2/python/plugins 4. You will see a con rmation dialog once your plugin template is created. you will be prompted to choose a directory for your plugin. type make . 6. Once you are in the directory.qrc le that was created by Plugin Builder. Launch the OSGeo4W Shell on windows or a terminal on Mac or Linux. 5.qgis2\python\plugins\SaveAttributes 7. cd c:\Users\username\. . This will run the pyrcc4 command that we had installed as part of Qt bindings for Python. Before we can use the newly created plugin. You can use the cd command followed by the path to the directory. we need to compile the resources. Browse to the plugin directory where the output of Plugin Builder was created. Now we are ready to have a rst look at the brand new plugin we created. Select it to launch the plugin dialog. You will notice a new blank dialog named Save Attributes.make 8. . Close QGIS and launch it again. 9. Close this dialog. You will notice that there is a new icon in the toolbar and a new menu entry under Vector ‣ Save Attributes ‣ Save Attributes as CSV`. Go to Plugins ‣ Manage and Install plugins and enable the Save Attributes plugin in the Installed tab. Drag it to the plugin dialog. We will now design our dialog box and add some user interface elements to it.10. Click Open... Browse to the plugin directory and select the save_attributes_dialog_base. 11.. You can drag-and-drop elements from the left-hand panel on the dialog. We will add a Combo Box type of Input Widget. 12. . You will see the blank dialog from the plugin. Open the Qt Creator program and to to File –> Open File or Project.ui le. 14.13. . Resize the combo box and adjust its size. Now drag a Label type Display Widget on the dialog. Click on the label text and enter Select a layer . we will have to refer to it by this name. Let’s reload our plugin so we can see the changes in the dialog window. . 16. Save this le by going to File ‣ Save save_attributes_dialog_base.ui. Go to Plugin ‣ Plugin Reloader ‣ Choose a plugin to be reloaded. Note the name of the combo box object is comboBox . To interact with this object using python code.15. 17. You will see the newly designed dialog box. Now click the Save Attributes as CSV button. Select SaveAttributes in the Configure Plugin reloader dialog. 18. . comboBox.append(layer.layers() layer_list = [] for layer in layers: layer_list.name()) self.legendInterface().dlg.py in a text editor. layers = self. Scroll down and nd the run(self) method. Go to the plugin directory and load the le save_attributes. Add the following code at the beginning of the method. This code gets the layers loaded in QGIS and adds it to the comboBox object from the plugin dialog. Let’s add some logic to the plugin that will populate the combo box with the layers loaded in QGIS.iface.19.addItems(layer_list) . This method will be called when you click the toolbar button or select the plugin menu item. You will see that our combo box is now populated with the layer names that are loaded in QGIS. Back in the main QGIS window. reload the plugin by going to Plugins ‣ Plugin Reloader ‣ Reload plugin: SaveAttributes. Alternatively. launch the plugin by going to Vector ‣ Save Attributes ‣ Save Attributes as CSV. After you load some data.20. . you can just press F5 . we must load some layers in QGIS. To test this new functionality. 21. Save the le. We will now add python code to open a le browser when the user clicks the .. Let’s add remaining user interface elements. Next. Note the object names of the widgets that we will have to use to interact with them.ui le. 23. push button and show the select path in the line edit widget.. Add a LineEdit type Input Widget that will show the output le path that the user has chosen. . Open the save_attributes. . Switch back to Qt Creator and load the save_attributes_dialog_base. Add QFileDialog to our list of imports at the top of the le. add a Push Button type Button and change the button label to ..22. Add a Label Display Widget and change the text to Select output file .py le in a text editor.. button is clicked. This code will open a le browser and populate the line edit widget with the path of the le that the user chose.setText(filename) 25.dlg.txt') self. This code will clear the previously loaded text (if any) in the line edit widget and also connect the select_output_file method to the clicked signal of the push button widget."". Add a new method called select_output_file with the following code. Now we need to add code so that when the .lineEdit..dlg. "Select output file ". '*. Scroll up to the __init__ method and add the following lines at the bottom.getSaveFileName(self. def select_output_file(self): filename = QFileDialog. .. select_output_file method is called.24. . button and select an output text le from your disk.pendingFields() fieldnames = [field. The explanation for this code can be found in Getting Started With Python Programming (getting_started_with_pyqgis.join(unicode(f[x]) for x in fieldnames) + '\n' unicode_line = line.dlg. you will be able to click the .comboBox.select_output_file) 26. nothing happens.self. Find the place in the run method where it says pass .'.html).text() output_file = open(filename..dlg.lineEdit. When you click OK on the plugin dialog.dlg.getFeatures(): line = '.currentIndex() selectedLayer = layers[selectedLayerIndex] fields = selectedLayer. If all went ne.dlg. 'w') selectedLayerIndex = self. Replace it with the code below. Back in QGIS.connect(self. We now have all the pieces in place to do just that.close() . filename = self. reload the plugin and open the Save Attributes` dialog. That is because we have not added the logic to pull attribute information from the layer and write it to the text le.clicked.encode('utf-8') output_file.lineEdit. 27.pushButton.name() for field in fields] for f in selectedLayer.clear() self.write(unicode_line) output_file. . Now our plugin is ready. Reload the plugin and try it out. Do not publish this plugin or upload it to the QGIS plugin repository. Note This plugin is for demonstration purpose only. You can zip the plugin directory and share it with your users. 28. Below is the full save_attributes.py le as a reference.org/) so that all QGIS users will be able to nd and download your plugin. If this was a real plugin. You will nd that the output text le you chose will have the attributes from the vector layer. They can unzip the contents to their plugin directory and try out your plugin.qgis. you would upload it to the QGIS Plugin Repository (https://plugins. load(locale_path) if qVersion() > '4.# -*.iface. you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation. :type message: str. 'SaveAttributes_{}. QFileDialog # Initialize Qt resources from file resources.qm'. :param message: String for translation. ------------------- begin : 2015-04-20 git sha : $Format:%H$ copyright : (C) 2015 by Ujaval Gandhi email : [email protected] import QSettings.translator.setObjectName(u'SaveAttributes') self.dlg.QtGui import QAction.3.dirname(__file__) # initialize locale locale = QSettings().format(locale)) if os. message): """Get the translation for a string using Qt translation API.toolbar.tr(u'&Save Attributes') # TODO: We are going to let the user set this up in a future iteration self.installTranslator(self. * * * ***************************************************************************/ """ from PyQt4.menu = self.actions = [] self. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time.path.iface = iface # initialize plugin directory self.clear() self.addToolBar(u'SaveAttributes') self.lineEdit.plugin_dir = os.connect(self.path class SaveAttributes: """QGIS Plugin Implementation.pushButton.com ***************************************************************************/ /*************************************************************************** * * * This program is free software.translator = QTranslator() self. We implement this ourselves since we do not inherit QObject. :type iface: QgsInterface """ # Save reference to the QGIS interface self. qVersion. 'i18n'.translator) # Create the dialog (after translation) and keep reference self.toolbar = self.exists(locale_path): self. QTranslator. or * * (at your option) any later version.value('locale/userLocale')[0:2] locale_path = os. iface): """Constructor. QCoreApplication from PyQt4.clicked.3': QCoreApplication.dlg.path.""" def __init__(self. QIcon. :rtype: QString """ .py import resources_rc # Import the code for the dialog from save_attributes_dialog import SaveAttributesDialog import os.dlg = SaveAttributesDialog() # Declare instance attributes self. either version 2 of the License.join( self. QString :returns: Translated version of message.select_output_file) # noinspection PyMethodMayBeStatic def tr(self.plugin_dir.coding: utf-8 -*- """ /*************************************************************************** SaveAttributes A QGIS plugin This plugin saves the attribute of the selected vector layer as a CSV file.path. :type callback: function :param enabled_flag: A flag indicating if the action should be enabled by default. parent=None): """Add a toolbar icon to the toolbar.translate('SaveAttributes'.menu.mainWindow()) . :type enabled_flag: bool :param add_to_menu: Flag indicating whether the action should also be added to the menu. Note that the action is also added to self.setStatusTip(status_tip) if whats_this is not None: action. icon_path. Can be a resource path (e.setWhatsThis(whats_this) if add_to_toolbar: self.tr(u'Save Attributes as CSV').actions.PyArgumentList.setEnabled(enabled_flag) if status_tip is not None: action. action) self.add_action( icon_path. Defaults to True.connect(callback) action.append(action) return action def initGui(self): """Create the menu entries and toolbar icons inside the QGIS GUI. enabled_flag=True. parent) action. :type add_to_menu: bool :param add_to_toolbar: Flag indicating whether the action should also be added to the toolbar. Defaults to True. callback=self. whats_this=None. :type status_tip: str :param parent: Parent widget for the new action. :type icon_path: str :param text: Text that should be shown in menu items for this action. add_to_menu=True. text.iface. :type text: str :param callback: Function to be called when the action is triggered.run. status_tip=None. message) def add_action( self. ':/plugins/foo/bar. Defaults None.toolbar. text=self.png') or a normal file system path.PyCallByClass return QCoreApplication.addAction(action) if add_to_menu: self. parent=self. :type parent: QWidget :param whats_this: Optional text to show in the status bar when the mouse pointer hovers over the action. Defaults to True.addPluginToVectorMenu( self. :rtype: QAction """ icon = QIcon(icon_path) action = QAction(icon. text.""" icon_path = ':/plugins/SaveAttributes/icon.g. add_to_toolbar=True. # noinspection PyTypeChecker. :param icon_path: Path to the icon for this action. :returns: The action that was created.triggered.iface. :type add_to_toolbar: bool :param status_tip: Optional text to show in a popup when mouse pointer hovers over the action. callback.png' self.actions list. then click the pushbutton to add a path.dlg.dlg.tr(u'&Save Attributes').txt') self.setText(filename) def run(self): """Run method that performs all the real work""" layers = self. action) self.dlg."".encode('utf-8') output_file.close() 48 Comments QGIS Tutorials and Tips 1 Login Sort by Best Recommend 4 ⤤ Share Join the discussion… Mark Owen-Falkenberg • 7 months ago Hi everybody.lineEdit.iface. def unload(self): """Removes the plugin menu item and icon from QGIS GUI.dlg.join(unicode(f[x]) for x in fieldnames) + '\n' unicode_line = line. filename = self.removeToolBarIcon(action) # remove the toolbar del self.name()) self.layers() layer_list = [] for layer in layers: layer_list.getFeatures(): line = '. "Select output file ". I am making a plugin where I want to add a folder path via a QFileDialog as in the above example.currentIndex() selectedLayer = layers[selectedLayerIndex] fields = selectedLayer.dlg..dlg. '*. 'w') selectedLayerIndex = self.delete the line containing pass and # substitute with your code.name() for field in fields] for f in selectedLayer.text() output_file = open(filename..getSaveFileName(self. I use the QFileDialog.actions: self.toolbar def select_output_file(self): filename = QFileDialog.comboBox.getExistingDirectory function and it all works fine.show() # Run the dialog event loop result = self. the opened window for choosing the path will re-open after I choose a path or close it.legendInterface().removePluginVectorMenu( self.addItems(layer_list) # show the dialog self.exec_() # See if OK was pressed if result: # Do something useful here . If I close the plugin a open it again the 'choose path' window will reopen 3 time and so on.lineEdit.comboBox.iface. However if I close the plugin and open it again.dlg.write(unicode_line) output_file.pendingFields() fieldnames = [field. Has anyone else experienced thia and is there a solution? 1△ ▽ • Reply • Share › Mark Owen-Falkenberg > Mark Owen-Falkenberg • 7 months ago screenshot .'.""" for action in self.append(layer.iface. dlg.GetLayer(0) AttributeError: 'NoneType' object has no attribute 'GetLayer' 1△ ▽ • Reply • Share › robson • a month ago Hi.connect(self. in select_output_file_5 layer = shapefile. and add them into the plugin using the files provided by the plugin builder. 1△ ▽ • Reply • Share › Ashwin Bhayal • a year ago Iam not able to import a shapfile to PostGIS using the same library(ogr). △ ▽ • Reply • Share › Manolis Panagiotakis > Ujaval Gandhi • a month ago i used it and it fixed the error but after this i try to run the app and pushButton doesn't work △ ▽ • Reply • Share › Mikhail Minin > Manolis Panagiotakis • a month ago .py.clicked. line 223. how to display the fields in a table selected in a combo box in another combobox? △ ▽ • Reply • Share › Manolis Panagiotakis • a month ago i did every step and at the end when i put line self.ui file.lineEdit. Make sure you have put self. Thank you for providing very helpful tutorials.dlg = SaveAttributesDialog() in the __init__ method.py file to use it. Oluwafemi Emmanuel • 7 months ago Hi All. I am using below link but it give me error.dlg.dlg is not defined.qgis2/python/plugins⧵Importtool⧵Import_tool. Then import the Dialog from that . Import shp to Postgis using Python and ogr Error : Traceback (most recent call last): File "C:/Users/n/. I am new to plugin dev and I was given a task to develop a plugin that can automatically update two field in a table with timestamp and also source with current timestamp and also the user name.py". Please anyone with help its urgent. To integrate the .py file into the save_attributes. △ ▽ • Reply • Share › Ooju.ui file you need to create a new . I am finding it difficult to find information on how to connect different QWidgets that were created independent of the .py file similar to save_attributes_dialog. Thanks 1△ ▽ • Reply • Share › Abby • a year ago Hi.select_output_file) i have this error bellow if i erase these lines it works again but when i put these lines it has problem △ ▽ • Reply • Share › Ujaval Gandhi Mod > Manolis Panagiotakis • a month ago The error means self.clear() self.pushButton. However. Which files provided by the plugin builder should these be added and where in the file? 1△ ▽ • Reply • Share › Ujaval Gandhi Mod > Abby • a year ago Good question. △ ▽ • Reply • Share › Ujaval Gandhi Mod > Axel Andersson • 4 months ago Good to know and thanks for sharing the correct syntax for the parameters.%f. I finally figure it out! import processing GRASS_REGION_PARAMETER = '%f. I had an extra space in the end which resulted in that no polygon file were created ("= '%f. I suppose one solution would be to save the plugin to a visible folder in QGIS. min_lat . But it doesn't work via the file picker in QGIS. I have a basic question: I can't display the .com/q. In the other plugin I want to use the heatmap plugin.dlg = SaveAttributesDialog() from add_action method △ ▽ • Reply • Share › Manolis Panagiotakis > Mikhail Minin • a month ago thank both of you for your help.actions()[0]. btw. path_and_file_name_point.qgis2 folder via the terminal..8. for interpolation . △ ▽ • Reply • Share › Sébastien Willis • 5 months ago Hi Ujaval Thanks for the very helpful tutorials.4. △ ▽ • Reply • Share › Ujaval Gandhi Mod > Axel Andersson • 5 months ago Most core functions have SIP bindings that can be used by python code.. I am new to plugin dev and I was given a task to develop a plugin that can automatically update two field in a table with timestamp and also source with current timestamp and also the user name.%f. I have tried changing the settings in the Terminal to display hidden folders. 3.%f.qgis2 folder directly? I am using OS X Yosemite and QGIS 2. instead of "= '%f. I've mange to start the plugins from python code: from PyQt4. False. What you are referring to are 'Core Plugins' which are not accessible by python. △ ▽ • Reply • Share › Axel Andersson • 5 months ago Thank you so much for this wonderful tutorial! I've made a couple of nice plugins after viewing this. △ ▽ • Reply • Share › Ooju.com/q. In 'Finder'. %f. both to no avail.rasterMenu()..you can use Processing.activate(QAction. 0.%f'% (min_lon.qgis2' manually to go to the folder. something that Interpolation does perfectly but I would like my plugin to determine all the input for Interpolation plugin.text(): item. %f '%" etc. you must also remove self.actions(): if "polation" in item.runandload("grass:v. GRASS_REGION_PARAMETER. %f. △ ▽ • Reply • Share › Axel Andersson > Ujaval Gandhi • 5 months ago Thanks a lot for the help. Please anyone with help its urgent.plugins['processing']. Instead . then manually move it using the Terminal to ~/.QtGui import QAction for item in qgis. Oluwafemi Emmanuel • 7 months ago Hi All.qgis2/python/plugins.%f'%" ) The only "problem" that remains now are that it takes rather long time to run the process with 100k+ points. Thanks △ ▽ • Reply • Share › . is there anyway to use core functions of QGIS? In one plugin I want to create polygons from points.voronoi".there is a Raster Interpolation python plugin that can be accessed via python http://gis.menu(). -1.iface. likewise I have tried selecting show hidden files when searching in QGIS. I would keep the plugin in another folder and create a symbolic link to it in the .. but this seems silly.Trigger) But I have no clue how to find the various fields (like the number of columns/row or where to store the file) in the Interpolation plugin.stackexchange. max_lat) processing. I'm however stuck now in two different plugins with a similar problem. Is there no way to find the . As a workaround.stackexchange.%f.qgis2 folder when I search for a directory to install the plugin to (step 3).False.utils. max_lon. Any suggestions are appreciated! △ ▽ • Reply • Share › Ujaval Gandhi Mod > Sébastien Willis • 5 months ago Ya this is strange. There are equivalent processing algorithms that can be programmatically configured and run via python http://gis. you can use Cmd+Shift+G and type '. path_and_file_name_poly) I had huge problems with getting the correct format for GRASS_REGION_PARAMETER. fill(color. 1024)..com/q. Also it is not displaying label names on print image. △ ▽ • Reply • Share › Ashwin Bhayal • a year ago Hi Ujaval.James Athersmith • 10 months ago Hi Ujaval.QtCore import * import time l = iface.qgis2/python/plugins⧵SaveAttributes⧵save_attributes. 255) img..qgistutorials. see my recommendations at http://www. 255.py".dataProvider(). I want to print only selected polygon.dlg. I am pretty new to PyQis and I am having some trouble figuring out on how I can use Python to get the path of a layer loaded on QGis. I have gone through the cookbook but it gives less explanation relating to plugin development.activeLayer() for a in l. . Any help would be greatly appreciated.rgb()) # create painter p = QPainter() p.setTest(filename) AttributeError: 'QLineEdit' object has no attribute 'setTest' Im getting the following error when I go to save a vector layer using the plugin. My code is the same as yours at the end of the tutorial. Please suggest some way. in select_output_file self.QtGui import * from PyQt4.. QImage. △ ▽ • Reply • Share › Ujaval Gandhi Mod > Milton Isaya • a year ago For the path.getFeatures(): attrs = {16: 1} l. △ ▽ • Reply • Share › Ujaval Gandhi Mod > James Athersmith • 8 months ago The correct method name is setText ..fullExtent()) with rect = layer.changeAttributeValues({a. I will also appreciate if you can assist me with some reliable resources relating to PyQGis plugin development.Format_ARGB32_Premultiplied) # set image's background color color = QColor(255.lineEdit. from PyQt4.id(): attrs}) img = QImage(QSize(1280.your code has setTest △ ▽ • Reply • Share › Ashwin Bhayal • a year ago i want to develop "Print lay out functionality". Traceback (most recent call last): File "C:/Users/AutoCad/. Thanks for your helpful tutorial. see http://gis.boundingBoxOfSelected() △ ▽ • Reply • Share › Milton Isaya • a year ago Hi Ujaval Gandhi. Below Question image. line 189. Thank you one again.stackexchange.begin(img) see more △ ▽ • Reply • Share › Ujaval Gandhi Mod > Ashwin Bhayal • a year ago replace rect = QgsRectangle(render. but in output system is giving me whole image.com/e. For general pyqgis resources. Please see below image. http://stackoverflow..x = 20 b.iface. Thank you for providing very helpful tutorials How can make sub menu of sub menu in QGIS. So how can I pass variable one module (impoarttool.. Can you explain me process? Ok Thanks △ ▽ • Reply • Share › Ujaval Gandhi Mod > Ashwin Bhayal • a year ago Intead of using self. and it would be logical to group them together under the same submenu. When we create new plugin in QGIS. . get a reference to appropriate menu. a.addPluginToVectorMenu to add the items.py from a import A class B: see more △ ▽ • Reply • Share › Ashwin Bhayal • a year ago Hi Ujaval.webMenu() and then add a sub-menu and actions in the standard QT way. These plugins are related.iface. When I am trying to below code it will give me error.py class A: def run(self): self.py). I would like to create two seperate plugins using the plugin builder.com/quest.py) to another module (Edit_from_B.△ ▽ • Reply • Share › Ashwin Bhayal • a year ago Hi Ujaval. For example webMenu = self. △ ▽ • Reply • Share › Joakim Mårtensson > Ujaval Gandhi • 7 months ago Could you please expand on that answer? For instance. Would you recommend another approach? thanks again △ ▽ • Reply • Share › Ujaval Gandhi Mod > Bubu Italia • a year ago @Bubu Italia Good catch. I realized the need to make that more explicit while teaching a in-person workshop so created this https://drive. △ ▽ • Reply • Share › 30plus > Ujaval Gandhi • 21 days ago I tried that fix. These tutorials have been a great help to learn how to develop plugins.clear() before the comboBox. make sure you have chosen the corret plugin to be reloaded. I will incorporate this into this tutorial. Python and Qt before installing OSGeo4w. Go to Plugins → Plugin Reloader → Choose a plugin to be reloaded and select 'SaveAttributes' △ ▽ • Reply • Share › Bubu Italia • a year ago Great Tutorial! Beginner question: if I run several times the plugin. you have to manually link all the libraries between the programs. it will download QGIS. I have to close qgis and open it again in order to reflect changes in the SaveAttributes plugin .google. Is there any real difference? △ ▽ • Reply • Share › jobanpreet • a year ago My plugin reloader doesn't seem to work . QGIS version: 2. Python version: 2. My workaround was to add self. Any updates on how to fix this (aesthetic) issue? △ ▽ • Reply • Share › GisLab • a year ago It is showing an error "Couldn't load plugin SaveAttributes1 due an error when calling its classFactory() method" "IndentationError: unexpected indent". Your approach is the right way to handle this. Python and Qt (And some other things) and configure them automatically. download only OSGeo4w and select the Desktop Express Install.But i've already checked the spacing and its correct . △ ▽ • Reply • Share › Pablo Adrian Q • a year ago Hi! I'm having problems in the step#7: When I try to run the 'make' command. 64 bits and a StandAlone installation. and thanks! *UPDATE* Already solved the issue. 1△ ▽ • Reply • Share › Pablo Adrian Q > Ujaval Gandhi • a year ago Thank you very much Ujaval. the combox shows an increasing list of shapefiles.addItems() call. I get the message: " 'make' is not recognized as an internal or external command..1 OSGeo4w: Installed with Express Desktop Install. Python and Qt without having to reinstall them.dlg." Any ideas on how can I solve this problem? Some additional information: I'm using Windows 8.7 Hope you can help me. with the same file repeated one more time at each launch. group them together under the same submenu. Managing dependencies and linking them is difficult to do manually so best let the OSGeo4W installer figure it out.combBox.. but I have been reading that there are differences between commands and syntaxis when using the Python console on QGIS and when writing a plugin.. The problem was that if you install QGIS. △ ▽ • Reply • Share › Ujaval Gandhi Mod > Pablo Adrian Q • a year ago Thanks Pablo Adrian Q for the feedback..com/file/. but I still get the first dataset in the QGIS TOC showing when I run the plugin. . Any idea why that might be happening? △ ▽ • Reply • Share › Ujaval Gandhi Mod > jobanpreet • a year ago In plugin reloader.10. it would be nice to include in this post how to link the libraries of QGIS. operable program or batch file. I don't know if this is the appropiate place to make a question. Surely there needs to be some code to check if the menu item has already been created etc. Still. As an advice. in startPlugin plugins[packageName] = package. Thank you. Try to write this line in another editor △ ▽ • Reply • Share › Danny Morck > Michał Włoga • a year ago As Michal noticed . I've got as far as typimg 'make' but get the error: "make: *** No targets specified and no makefile found.△ ▽ • Reply • Share › Ujaval Gandhi Mod > GisLab • a year ago Did you check Replace by space at Settings ‣ Preferences ‣ Tab Settings? △ ▽ • Reply • Share › Michał Włoga > Ujaval Gandhi • a year ago that's notepad++ problem. There is a Makefile in the folder now along with a resources.qgis2/python/plugins⧵MultiStats⧵__init__. △ ▽ • Reply • Share › Mark Percival > Ujaval Gandhi • a year ago Ah! Didn't change to the folder. line 34. Thanks Ujaval.multistats import MultiStats .py". _re. line 219. Maybe this should be mentioned in the tutorial. △ ▽ • Reply • Share › Mark Percival > Mark Percival • a year ago I'm now getting the following error when I put the comboBox code into my py file! Couldn't load plugin MultiStats due to an error when calling its classFactory() method Traceback (most recent call last): File "C:/OSGEO4~1/apps/qgis/.qrc.py". in classFactory from .py etc. Make sure you changed to the directory where the plugin was saved./python⧵qgis⧵utils. Stop.classFactory(iface) File "C:/Users/mpercival/." I've got the latest QGIS and QT installed Windows 7 Pro with full Admin access I'm not sure where I go from here! Mark △ ▽ • Reply • Share › Ujaval Gandhi Mod > Mark Percival • a year ago run dir and see if there is a Makefile in the current directory.it´s a problem in Notepad ++. △ ▽ • Reply • Share › Ujaval Gandhi Mod > Danny Morck • a year ago I have added a note in the 'Text Editor' section in the tutorial △ ▽ • Reply • Share › Mark Percival • a year ago Hi Ujaval.
Report "Building a Python Plugin — QGIS Tutorials and Tips"