Example #1
0
    def OnUpdatePlugins(self, msg):
        """Update the location of the user plugins and load all plugins."""

        self.userpluginpath = msg.data
        # Load the plugins only if they haven't been loaded previously
        if not len(self.plugins):
            self.plugins = plugin.import_plugins(self.userpluginpath)
            self.menuDict = {}
            self.menuImportDict = {}
            self.menuExportDict = {}
            # Set up the import plugins for dicompyler
            for i, p in enumerate(self.plugins):
                props = p.pluginProperties()
                # Only load plugin versions that are qualified
                if (props["plugin_version"] == 1) and (props["plugin_type"] == "import"):
                    self.menuImportItem.Enable(True)
                    # Load the import menu plugins
                    if not len(self.menuImportDict):
                        self.menuImportItem.Enable(True)
                    self.menuImportDict[300 + i] = self.menuImport.Append(300 + i, props["menuname"])
                    pi = p.plugin(self)
                    self.Bind(wx.EVT_MENU, pi.pluginMenu, id=300 + i)
                    # If the import plugin has toolbar items, display them
                    if hasattr(pi, "tools"):
                        for t, tool in enumerate(pi.tools):
                            self.maintools.append(tool)
                            self.toolbar.AddLabelTool(
                                (300 + i) * 10 + t, tool["label"], tool["bmp"], shortHelp=tool["shortHelp"]
                            )
                            self.Bind(wx.EVT_TOOL, tool["eventhandler"], id=(300 + i) * 10 + t)
                        self.toolbar.Realize()
Example #2
0
    def OnUpdatePlugins(self, topic, msg):
        """Update the location of the user plugins and load all plugins."""

        self.userpluginpath = msg
        # Load the plugins only if they haven't been loaded previously
        if not len(self.plugins):
            self.plugins = plugin.import_plugins(self.userpluginpath)
            self.menuDict = {}
            self.menuImportDict = {}
            self.menuExportDict = {}
            # Set up the import plugins for dicompyler
            for i, pg in enumerate(self.plugins):
                # Skip plugin if it doesn't contain the required dictionary
                # or actually is a proper Python module or is disabled
                p = pg["plugin"]
                if not hasattr(p, "pluginProperties") or (
                        p.__name__ in self.pluginsDisabled):
                    continue
                props = p.pluginProperties()
                # Only load plugin versions that are qualified
                if (props["plugin_version"] == 1) and (props["plugin_type"]
                                                       == "import"):
                    self.menuImportItem.Enable(True)
                    # Load the import menu plugins
                    if not len(self.menuImportDict):
                        self.menuImportItem.Enable(True)
                    self.menuImportDict[300 + i] = self.menuImport.Append(
                        300 + i, props["menuname"])
                    pi = p.plugin(self)
                    self.Bind(wx.EVT_MENU, pi.pluginMenu, id=300 + i)
                    # If the import plugin has toolbar items, display them
                    if hasattr(pi, "tools"):
                        for t, tool in enumerate(pi.tools):
                            self.maintools.append(tool)
                            self.toolbar.AddTool(
                                (300 + i) * 10 + t,
                                tool["label"],
                                tool["bmp"],
                                shortHelp=tool["shortHelp"],
                            )
                            self.Bind(wx.EVT_TOOL,
                                      tool["eventhandler"],
                                      id=(300 + i) * 10 + t)
                        self.toolbar.Realize()
Example #3
0
    def OnUpdatePlugins(self, topic, msg):
        """Update the location of the user plugins and load all plugins."""

        self.userpluginpath = msg
        # Load the plugins only if they haven't been loaded previously
        if not len(self.plugins):
            self.plugins = plugin.import_plugins(self.userpluginpath)
            self.menuDict = {}
            self.menuImportDict = {}
            self.menuExportDict = {}
            # Set up the import plugins for dicompyler
            for i, pg in enumerate(self.plugins):
                # Skip plugin if it doesn't contain the required dictionary
                # or actually is a proper Python module or is disabled
                p = pg['plugin']
                if not hasattr(p, 'pluginProperties') or \
                    (p.__name__ in self.pluginsDisabled):
                    continue
                props = p.pluginProperties()
                # Only load plugin versions that are qualified
                if ((props['plugin_version'] == 1) and
                    (props['plugin_type'] == 'import')):
                    self.menuImportItem.Enable(True)
                    # Load the import menu plugins
                    if not len(self.menuImportDict):
                        self.menuImportItem.Enable(True)
                    self.menuImportDict[300+i] = self.menuImport.Append(
                                        300+i, props['menuname'])
                    pi = p.plugin(self)
                    self.Bind(wx.EVT_MENU, pi.pluginMenu, id=300+i)
                    # If the import plugin has toolbar items, display them
                    if hasattr(pi, 'tools'):
                        for t, tool in enumerate(pi.tools):
                            self.maintools.append(tool)
                            self.toolbar.AddTool(
                                        (300+i)*10+t, tool['label'],
                                        tool['bmp'], shortHelp=tool['shortHelp'])
                            self.Bind(wx.EVT_TOOL, tool['eventhandler'], id=(300+i)*10+t)
                        self.toolbar.Realize()