Esempio n. 1
0
class AuxiliaryWindowPlugin:
    def __init__(self, iface):
        self.iface = iface
        self.plugin = ContainerAuxiliaryWindow(iface.mainWindow())
        self.namePlugin = "&Auxiliary Window"

    def _connect(self, isConnect=True):
        signal_slot = ({
            'signal': QgsProject.instance().readProject,
            'slot': self.plugin.onReadProject
        }, {
            'signal': QgsProject.instance().writeProject,
            'slot': self.plugin.onWriteProject
        })
        if isConnect:
            for item in signal_slot:
                item['signal'].connect(item['slot'])
        else:
            for item in signal_slot:
                item['signal'].disconnect(item['slot'])

    def initGui(self):
        title = "Auxiliary window"
        icon = QIcon(
            os.path.join(os.path.dirname(__file__), 'auxiliarywindow.png'))
        self.action = QAction(icon, title, self.iface.mainWindow())
        self.action.setObjectName("AuxiliaryWindow")
        self.action.setWhatsThis(title)
        self.action.setStatusTip(title)
        self.action.triggered.connect(self.run)
        self.iface.addToolBarIcon(self.action)
        self.iface.addPluginToMenu(self.namePlugin, self.action)
        self._connect()

    def unload(self):
        self.iface.removeToolBarIcon(self.action)
        self.iface.removePluginMenu(self.namePlugin, self.action)
        del self.action
        self._connect(False)
        self.plugin.close()

    @pyqtSlot()
    def run(self):
        self.plugin.run()
Esempio n. 2
0
class AuxiliaryWindowPlugin:

  def __init__(self, iface):
    self.iface = iface
    self.plugin = ContainerAuxiliaryWindow( iface.mainWindow() )
    self.namePlugin = "&Auxiliary Window"

  def _connect(self, isConnect = True):
    signal_slot = (
      { 'signal': QgsProject.instance().readProject, 'slot': self.plugin.onReadProject },
      { 'signal': QgsProject.instance().writeProject, 'slot': self.plugin.onWriteProject }
    )
    if isConnect:
      for item in signal_slot:
        item['signal'].connect( item['slot'] )
    else:
      for item in signal_slot:
        item['signal'].disconnect( item['slot'] )

  def initGui(self):
    title = "Auxiliary window"
    icon = QIcon( os.path.join( os.path.dirname(__file__), 'auxiliarywindow.png' ) )
    self.action = QAction( icon, title, self.iface.mainWindow() )
    self.action.setObjectName( "AuxiliaryWindow" )
    self.action.setWhatsThis( title )
    self.action.setStatusTip( title )
    self.action.triggered.connect( self.run )
    self.iface.addToolBarIcon( self.action )
    self.iface.addPluginToMenu( self.namePlugin, self.action)
    self._connect()

  def unload(self):
    self.iface.removeToolBarIcon( self.action )
    self.iface.removePluginMenu( self.namePlugin, self.action)
    del self.action
    self._connect( False )
    self.plugin.close()
  
  @pyqtSlot()
  def run(self):
    self.plugin.run()
Esempio n. 3
0
 def __init__(self, iface):
   self.iface = iface
   self.plugin = ContainerAuxiliaryWindow( iface.mainWindow() )
   self.namePlugin = "&Auxiliary Window"
Esempio n. 4
0
 def __init__(self, iface):
     self.iface = iface
     self.plugin = ContainerAuxiliaryWindow(iface.mainWindow())
     self.namePlugin = "&Auxiliary Window"