class QuickWKT: def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface self.canvas = iface.mapCanvas() def initGui(self): # Create action that will start plugin self.action = QAction(QIcon(":/plugins/QuickWKT/quickwkt_icon.png"), \ "&QuickWKT", self.iface.mainWindow()) # connect the action to the run method QObject.connect(self.action, SIGNAL("activated()"), self.quickwkt) # Add toolbar button and menu item self.aboutAction=QAction(QIcon(":/plugins/QuickWKT/about_icon.png"), QCoreApplication.translate('QuickWKT', "&About"), self.iface.mainWindow()) QObject.connect(self.aboutAction, SIGNAL("activated()"), self.about) self.iface.addToolBarIcon(self.action) self.iface.addPluginToMenu("QuickWKT", self.action) self.iface.addPluginToMenu("QuickWKT", self.aboutAction) # create dialog examples = """examples:\nPOINT(-5 10)\nLINESTRING(-0 0, 10 10, 20 0, 0 -20)\nPOLYGON((-0 0, 10 10, 10 -10, 0 0))\nPOLYGON ((35 10, 10 20, 15 40, 45 45, 35 10), (20 30, 35 35, 30 20, 20 30)) polygon with hole\nMULTIPOINT ((10 40), (40 30), (20 20), (30 10))""" self.dlg = QuickWKTDialog() self.dlg.wkt.setPlainText(examples) def unload(self): # Remove the plugin menu item and icon self.iface.removePluginMenu("QuickWKT",self.action) self.iface.removeToolBarIcon(self.action) def about(self): infoString = QString(QCoreApplication.translate('QuickWKT', "Python QuickWKT Plugin<br />This plugin creates a set of temporary layers and populates them with WKT features that you can paste in a dialog window.<br /><strong>All layers created by this plugins are temporary layers, all data will be lost when you quit QGIS.</strong><br />Author: Dr. Alessandro Pasotti (aka: elpaso)<br />Mail: <a href=\"mailto:[email protected]\">[email protected]</a><br />Web: <a href=\"http://www.itopen.it\">www.itopen.it</a>\n")) QMessageBox.information(self.iface.mainWindow(), "About QuickWKT",infoString) # run def quickwkt(self): # show the dialog self.dlg.show() result = self.dlg.exec_() # See if OK was pressed if result == 1 and self.dlg.wkt.toPlainText(): try: self.save_wkt(unicode(self.dlg.wkt.toPlainText())) except Exception, e: QMessageBox.information(self.iface.mainWindow(), QCoreApplication.translate('QuickWKT', "QuickWKT plugin error"), QCoreApplication.translate('QuickWKT', "There was an error with the service:<br /><strong>%1</strong>").arg(unicode(e))) return # Refresh the map self.canvas.refresh() return
def initGui(self): # Create action that will start plugin self.action = QAction(QIcon(":/plugins/QuickWKT/quickwkt_icon.png"), \ "&QuickWKT", self.iface.mainWindow()) # connect the action to the run method self.action.triggered.connect(self.quickwkt) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) self.iface.addPluginToMenu("QuickWKT", self.action) # create dialog examples = "" self.dlg = QuickWKTDialog() self.dlg.wkt.setPlainText(examples) self.dlg.layerTitle.setText('QuickWKT') self.dlg.clearButton.clicked.connect(self.clearButtonClicked)
def initGui(self): # Create action that will start plugin self.action = QAction(QIcon(":/plugins/QuickWKT/quickwkt_icon.png"), \ "&QuickWKT", self.iface.mainWindow()) # connect the action to the run method QObject.connect(self.action, SIGNAL("activated()"), self.quickwkt) # Add toolbar button and menu item self.aboutAction = QAction( QIcon(":/plugins/QuickWKT/about_icon.png"), QCoreApplication.translate('QuickWKT', "&About"), self.iface.mainWindow()) QObject.connect(self.aboutAction, SIGNAL("activated()"), self.about) self.iface.addToolBarIcon(self.action) self.iface.addPluginToMenu("QuickWKT", self.action) self.iface.addPluginToMenu("QuickWKT", self.aboutAction) # create dialog #examples = """examples:\nPOINT(-5 10)\nLINESTRING(-0 0, 10 10, 20 0, 0 -20)\nPOLYGON((-0 0, 10 10, 10 -10, 0 0))\nPOLYGON ((35 10, 10 20, 15 40, 45 45, 35 10), (20 30, 35 35, 30 20, 20 30)) \npolygon with hole\nMULTIPOINT ((10 40), (40 30), (20 20), (30 10))""" examples = "" self.dlg = QuickWKTDialog() self.dlg.wkt.setPlainText(examples)
def initGui(self): # Create action that will start plugin self.action = QAction(QIcon(":/plugins/QuickWKT/quickwkt_icon.png"), "&QuickWKT", self.iface.mainWindow()) # connect the action to the run method self.action.triggered.connect(self.quickwkt) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) self.iface.addPluginToMenu("QuickWKT", self.action) # create dialog examples = "" self.dlg = QuickWKTDialog() self.dlg.wkt.setPlainText(examples) self.dlg.layerTitle.setText("QuickWKT") self.dlg.clearButton.clicked.connect(self.clearButtonClicked)
def initGui(self): # Create action that will start plugin self.action = QAction(QIcon(":/plugins/QuickWKT/quickwkt_icon.png"), \ "&QuickWKT", self.iface.mainWindow()) # connect the action to the run method QObject.connect(self.action, SIGNAL("activated()"), self.quickwkt) # Add toolbar button and menu item self.aboutAction = QAction(QIcon(":/plugins/QuickWKT/about_icon.png"), QCoreApplication.translate('QuickWKT', "&About"), self.iface.mainWindow()) QObject.connect(self.aboutAction, SIGNAL("activated()"), self.about) self.iface.addToolBarIcon(self.action) self.iface.addPluginToMenu("QuickWKT", self.action) self.iface.addPluginToMenu("QuickWKT", self.aboutAction) # create dialog # examples = """examples:\nPOINT(-5 10)\nLINESTRING(-0 0, 10 10, 20 0, 0 -20)\nPOLYGON((-0 0, 10 10, 10 -10, 0 0))\nPOLYGON ((35 10, 10 20, 15 40, 45 45, 35 10), (20 30, 35 35, 30 20, 20 30)) \npolygon with hole\nMULTIPOINT ((10 40), (40 30), (20 20), (30 10))""" examples = "" self.dlg = QuickWKTDialog() self.dlg.wkt.setPlainText(examples)
class QuickWKT: def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface self.canvas = iface.mapCanvas() # TODO: remove: unused self.layerNum = 1 iface.show_wkt = self.save_wkt iface.show_wkb = self.save_wkb iface.show_geometry = self.save_geometry def initGui(self): # Create action that will start plugin self.action = QAction(QIcon(":/plugins/QuickWKT/quickwkt_icon.png"), \ "&QuickWKT", self.iface.mainWindow()) # connect the action to the run method self.action.triggered.connect(self.quickwkt) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) self.iface.addPluginToMenu("QuickWKT", self.action) # create dialog examples = "" self.dlg = QuickWKTDialog() self.dlg.wkt.setPlainText(examples) self.dlg.layerTitle.setText('QuickWKT') self.dlg.clearButton.clicked.connect(self.clearButtonClicked) def clearButtonClicked(self): self.dlg.wkt.setPlainText('') def unload(self): # Remove the plugin menu item and icon self.iface.removePluginMenu("QuickWKT", self.action) self.iface.removeToolBarIcon(self.action) # run def quickwkt(self): # show the dialog self.dlg.show() self.dlg.adjustSize() result = self.dlg.exec_() # See if OK was pressed if result == 1 and self.dlg.wkt.toPlainText(): text = unicode(self.dlg.wkt.toPlainText()) layerTitle = self.dlg.layerTitle.text() or 'QuickWKT' try: if "(" in text: self.save_wkt(text, layerTitle) else: self.save_wkb(text, layerTitle) except Exception, e: # Cut message = self.constraintMessage(unicode(e)) QMessageBox.information(self.iface.mainWindow(), \ QCoreApplication.translate('QuickWKT', "QuickWKT plugin error"), \ QCoreApplication.translate('QuickWKT', "There was an error with the service:<br /><strong>{0}</strong>").format(message)) return # Refresh the map self.canvas.refresh() return
class QuickWKT: def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface self.canvas = iface.mapCanvas() # TODO: remove: unused self.layerNum = 1 iface.show_wkt = self.save_wkt iface.show_wkb = self.save_wkb iface.show_geometry = self.save_geometry def initGui(self): # Create action that will start plugin self.action = QAction(QIcon(":/plugins/QuickWKT/quickwkt_icon.png"), "&QuickWKT", self.iface.mainWindow()) # connect the action to the run method self.action.triggered.connect(self.quickwkt) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) self.iface.addPluginToMenu("QuickWKT", self.action) # create dialog examples = "" self.dlg = QuickWKTDialog() self.dlg.wkt.setPlainText(examples) self.dlg.layerTitle.setText("QuickWKT") self.dlg.clearButton.clicked.connect(self.clearButtonClicked) def clearButtonClicked(self): self.dlg.wkt.setPlainText("") def unload(self): # Remove the plugin menu item and icon self.iface.removePluginMenu("QuickWKT", self.action) self.iface.removeToolBarIcon(self.action) # run def quickwkt(self): # show the dialog self.dlg.show() self.dlg.adjustSize() result = self.dlg.exec_() # See if OK was pressed if result == 1 and self.dlg.wkt.toPlainText(): text = unicode(self.dlg.wkt.toPlainText()) layerTitle = self.dlg.layerTitle.text() or "QuickWKT" try: if "(" in text: self.save_wkt(text, layerTitle) else: self.save_wkb(text, layerTitle) except Exception, e: QMessageBox.information( self.iface.mainWindow(), QCoreApplication.translate("QuickWKT", "QuickWKT plugin error"), QCoreApplication.translate( "QuickWKT", "There was an error with the service:<br /><strong>{0}</strong>" ).format(unicode(e)), ) return # Refresh the map self.canvas.refresh() return
class QuickWKT: def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface self.canvas = iface.mapCanvas() self.layerNum = 1 def initGui(self): # Create action that will start plugin self.action = QAction(QIcon(":/plugins/QuickWKT/quickwkt_icon.png"), \ "&QuickWKT", self.iface.mainWindow()) # connect the action to the run method QObject.connect(self.action, SIGNAL("activated()"), self.quickwkt) # Add toolbar button and menu item self.aboutAction = QAction( QIcon(":/plugins/QuickWKT/about_icon.png"), QCoreApplication.translate('QuickWKT', "&About"), self.iface.mainWindow()) QObject.connect(self.aboutAction, SIGNAL("activated()"), self.about) self.iface.addToolBarIcon(self.action) self.iface.addPluginToMenu("QuickWKT", self.action) self.iface.addPluginToMenu("QuickWKT", self.aboutAction) # create dialog #examples = """examples:\nPOINT(-5 10)\nLINESTRING(-0 0, 10 10, 20 0, 0 -20)\nPOLYGON((-0 0, 10 10, 10 -10, 0 0))\nPOLYGON ((35 10, 10 20, 15 40, 45 45, 35 10), (20 30, 35 35, 30 20, 20 30)) \npolygon with hole\nMULTIPOINT ((10 40), (40 30), (20 20), (30 10))""" examples = "" self.dlg = QuickWKTDialog() self.dlg.wkt.setPlainText(examples) def unload(self): # Remove the plugin menu item and icon self.iface.removePluginMenu("QuickWKT", self.action) self.iface.removeToolBarIcon(self.action) def about(self): infoString = QString( QCoreApplication.translate( 'QuickWKT', "Python QuickWKT Plugin<br />This plugin creates a set of temporary layers and populates them with WKT features that you can paste in a dialog window.<br /><strong>All layers created by this plugins are temporary layers, all data will be lost when you quit QGIS.</strong><br />Author: Dr. Alessandro Pasotti (aka: elpaso)<br />Mail: <a href=\"mailto:[email protected]\">[email protected]</a><br />Web: <a href=\"http://www.itopen.it\">www.itopen.it</a>\n" )) QMessageBox.information(self.iface.mainWindow(), "About QuickWKT", infoString) # run def quickwkt(self): # show the dialog self.dlg.show() result = self.dlg.exec_() # See if OK was pressed if result == 1 and self.dlg.wkt.toPlainText(): text = unicode(self.dlg.wkt.toPlainText()) try: if "(" in text: self.save_wkt(text) else: self.save_wkb(text) except Exception, e: QMessageBox.information(self.iface.mainWindow(), \ QCoreApplication.translate('QuickWKT', "QuickWKT plugin error"), \ QCoreApplication.translate('QuickWKT', "There was an error with the service:<br /><strong>%1</strong>").arg(unicode(e))) return # Refresh the map self.canvas.refresh() return