Plugin initialization¶
Create QGIS project¶
Use Add vector layer or Ctrl+Shift+V. Add multiple layers to your new QGIS project.
, iconActivate plugin¶
In
search and activate the Save Views plugin.Qt Designer¶
Start the Qt Desginer tool and open the
save_views_dockwidget_base.ui
file.
The code¶
The key file is save_views.py
and the run()
method:
1 def run(self):
2 """Run method that loads and starts the plugin"""
3
4 if not self.pluginIsActive:
5 self.pluginIsActive = True
6
7 #print "** STARTING SaveViews"
8
9 # dockwidget may not exist if:
10 # first run of plugin
11 # removed on close (see self.onClosePlugin method)
12 if self.dockwidget == None:
13 # Create the dockwidget (after translation) and keep reference
14 self.dockwidget = SaveViewsDockWidget()
15
16 # connect to provide cleanup on closing of dockwidget
17 self.dockwidget.closingPlugin.connect(self.onClosePlugin)
18
19 # show the dockwidget
20 # TODO: fix to allow choice of dock location
21 self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.dockwidget)
22 self.dockwidget.show()
Note
The code can be downloaded from our Github.