def initGui(self):
        icon = QIcon(':/plugins/qgis-report-plugin/images/icon.png')
        self.action = QAction(icon, "Report!", iface.mainWindow())
        self.action.triggered.connect(self.run)
        iface.addToolBarIcon(self.action)

        # hook to exception handling
        global old_show_exception
        old_show_exception = qgis.utils.showException
        qgis.utils.showException = show_report_exception
Пример #2
0
    def initGui(self):
        '''
        Here wew add the main menu entry, used to enable the map tool to 
        capture coordinates
        '''
        mapToolIcon = QIcon(
            os.path.join(os.path.dirname(__file__), "icons", "w3w.png"))
        self.toolAction = QAction(mapToolIcon, "what3words map tool",
                                  iface.mainWindow())
        self.toolAction.triggered.connect(self.setTool)

        #checkable = true, so it indicates whether the maptool is active or not
        self.toolAction.setCheckable(True)

        iface.addToolBarIcon(self.toolAction)
        iface.addPluginToMenu("what3words", self.toolAction)
        '''And here we add another tool to zoom to a w3w address'''
        zoomToIcon = QIcon(':/images/themes/default/mActionZoomIn.svg')
        self.zoomToAction = QAction(zoomToIcon, "Zoom to 3 word address",
                                    iface.mainWindow())
        self.zoomToAction.triggered.connect(self.zoomTo)
        iface.addPluginToMenu("what3words", self.zoomToAction)

        #Standard plugin menus provided by the qgiscommons library
        addSettingsMenu("what3words", iface.addPluginToMenu)
        addHelpMenu("what3words", iface.addPluginToMenu)
        addAboutMenu("what3words", iface.addPluginToMenu)
        '''
        This plugin uses a maptool. When another maptool is selected, our 
        plugin maptool will be disconnected, and we need to update the menu 
        entry, so it does not show itself as enabled. When the new tool is set, 
        it will fire a signal. We connect it to our unsetTool method, which 
        will handle this.
        '''
        iface.mapCanvas().mapToolSet.connect(self.unsetTool)
        '''
        We use a docked widget. We create it here and hide it, so when it is 
        called by the user, it is just set to visible and will be displayed in 
        its corresponding location in the app window.
        '''
        self.zoomToDialog = W3WCoordInputDialog(iface.mapCanvas(),
                                                iface.mainWindow())
        iface.addDockWidget(Qt.TopDockWidgetArea, self.zoomToDialog)
        self.zoomToDialog.hide()
        '''Add the Processing provider if Processing is availabel and loaded'''
        if processingOk:
            Processing.addProvider(self.provider)
Пример #3
0
    def initProcessing(self):
        self.provider = MappiaPublisherProvider()
        QgsApplication.processingRegistry().addProvider(self.provider)

        self.shareAction = QAction(
            QIcon(os.path.join(os.path.dirname(__file__), "icon_share.png")),
            u"Share your maps", iface.mainWindow())
        self.shareAction.triggered.connect(self.publishCallback)
        iface.addPluginToWebMenu(u"&Mappia", self.shareAction)
        iface.addToolBarIcon(self.shareAction)

        self.viewAction = QAction(
            QIcon(os.path.join(os.path.dirname(__file__), "icon_view.png")),
            u"View shared maps", iface.mainWindow())
        self.viewAction.triggered.connect(self.viewMapsCallback)
        iface.addPluginToWebMenu(u"&Mappia", self.viewAction)
        iface.addToolBarIcon(self.viewAction)
Пример #4
0
    def add_action(
        self,
        icon_path: str,
        text: str,
        callback: Callable,
        enabled_flag: bool = True,
        add_to_menu: bool = True,
        add_to_toolbar: bool = True,
        status_tip: Optional[str] = None,
        whats_this: Optional[str] = None,
        parent: Optional[QWidget] = None,
    ) -> QAction:
        """Add a toolbar icon to the toolbar.

        :param icon_path: Path to the icon for this action. Can be a resource
            path (e.g. ':/plugins/foo/bar.png') or a normal file system path.

        :param text: Text that should be shown in menu items for this action.

        :param callback: Function to be called when the action is triggered.

        :param enabled_flag: A flag indicating if the action should be enabled
            by default. Defaults to True.

        :param add_to_menu: Flag indicating whether the action should also
            be added to the menu. Defaults to True.

        :param add_to_toolbar: Flag indicating whether the action should also
            be added to the toolbar. Defaults to True.

        :param status_tip: Optional text to show in a popup when mouse pointer
            hovers over the action.

        :param parent: Parent widget for the new action. Defaults None.

        :param whats_this: Optional text to show in the status bar when the
            mouse pointer hovers over the action.

        :returns: The action that was created. Note that the action is also
            added to self.actions list.
        :rtype: QAction
        """

        icon = QIcon(icon_path)
        action = QAction(icon, text, parent)
        # noinspection PyUnresolvedReferences
        action.triggered.connect(callback)
        action.setEnabled(enabled_flag)

        if status_tip is not None:
            action.setStatusTip(status_tip)

        if whats_this is not None:
            action.setWhatsThis(whats_this)

        if add_to_toolbar:
            # Adds plugin icon to Plugins toolbar
            iface.addToolBarIcon(action)

        if add_to_menu:
            iface.addPluginToMenu(self.menu, action)

        self.actions.append(action)

        return action
        if lyr.name() == "Exonerados":
            layer = iface.setActiveLayer(lyr)
            #iface.messageBar().pushMessage("", 'La capa activa es ' + lyr.name(), duration=10)
            iface.actionIdentify().trigger()
            break
        if lyr.name() == "Zona":
            layer = iface.setActiveLayer(lyr)
            #iface.messageBar().pushMessage("", 'La capa activa es ' + lyr.name(), duration=10)
            iface.actionIdentify().trigger()
            break


action1 = QAction('Informacion de la capa principal')
action1.triggered.connect(boton)
action1.setIcon(QIcon(icon_path))
iface.addToolBarIcon(action1)

icon1 = 'metro.svg'
data_dir1 = os.path.join(os.path.expanduser('~'), 'D:/GIS_GPA/svg/')
icon_path1 = os.path.join(data_dir1, icon1)


def show_time():
    #now = datetime.now()
    #current_time = now.strftime("%H:%M:%S")
    #iface.messageBar().pushMessage('LA HORA ES {}'.format(current_time))
    layer = None
    for lyr in QgsProject.instance().mapLayers().values():
        if lyr.name() == "Lecturas por Predios":
            layer = iface.setActiveLayer(lyr)
            lyr.setSubsetString("")