def run(self): """ Running the plugin """ otf = self.iface.mapCanvas().mapRenderer().hasCrsTransformEnabled() if otf: message = "There might be wrong results with OTF switched on." \ "Please switch it off and chainage the layer you want to" show_warning(self, message) leave = -1 for layer in self.iface.mapCanvas().layers(): if layer.type() == QgsMapLayer.VectorLayer and \ layer.geometryType() == QGis.Line: leave += 1 if leave < 0: message = "No layers with line features - chainage not useful!" show_warning(self, message) return # show the dialog dialog = QChainageDialog(self.iface) # Run the dialog event loop result = dialog.exec_() # See if OK was pressed if result == 1: # do something useful (delete the line containing pass and # substitute with your code) pass
def run(self): """ Running the plugin """ leave = -1 for layer in self.iface.mapCanvas().layers(): if layer.type() == QgsMapLayer.VectorLayer and \ layer.geometryType() == QGis.Line: leave += 1 if leave < 0: message = QCoreApplication.translate('qchainage', "No layers with line features - chainage not useful!") mb = self.iface.messageBar() mb.pushWidget(mb.createMessage(message), QgsMessageBar.WARNING, 5) return # show the dialog dialog = QChainageDialog(self.iface) # Run the dialog event loop result = dialog.exec_() # See if OK was pressed if result == 1: # do something useful (delete the line containing pass and # substitute with your code) pass
def run(self): """ Running the plugin """ # show the dialog dialog = QChainageDialog(self.iface) # Run the dialog event loop result = dialog.exec_() # See if OK was pressed if result == 1: # do something useful (delete the line containing pass and # substitute with your code) pass