def __initActions(self):
        """
        Private method to initialize the actions.
        """
        # lists begining of action names which will be grouped 
        self.snippetDictionary={}
        psmp=SnippetMenuParser()
        snippetFilePath=os.path.abspath(os.path.join(os.path.dirname(__file__),'CC3DPythonHelper/Snippets.py.template'))
        
        psmp.readSnippetMenu(snippetFilePath)

        snippetMenuDict=psmp.getSnippetMenuDict()
        # print 'snippet menu dict = ',snippetMenuDict
        
        

        for menuName, submenuDict in iter(sorted(snippetMenuDict.iteritems())):
            print 'menuName=',menuName
            
            groupMenu=self.cc3dPythonMenu.addMenu(menuName)
            
            for subMenuName, snippetText in  iter(sorted(submenuDict.iteritems())):
                action=groupMenu.addAction(subMenuName)
                
                actionKey=menuName.strip()+' '+subMenuName.strip() # for lookup int he self.snippetDictionary 
                self.snippetDictionary[actionKey]=snippetText
                
                self.actions[actionKey]=action
                self.__ui.connect(action,SIGNAL("triggered()"),self.snippetMapper,SLOT("map()"))
                self.snippetMapper.setMapping(action, actionKey)
Ejemplo n.º 2
0
    def __initActions(self):
        """
        Private method to initialize the actions.
        """
        # lists begining of action names which will be grouped

        self.snippetDictionary = {}
        psmp = SnippetMenuParser()
        snippetFilePath = os.path.abspath(
            os.path.join(os.path.dirname(__file__),
                         'CC3DPythonHelper/Snippets.py.template'))

        psmp.readSnippetMenu(snippetFilePath)

        snippetMenuDict = psmp.getSnippetMenuDict()
        # print 'snippet menu dict = ',snippetMenuDict

        for menuName, submenuDict in iter(sorted(snippetMenuDict.iteritems())):
            print 'menuName=', menuName

            groupMenu = self.cc3dPythonMenu.addMenu(menuName)

            # for subMenuName, snippetText in iter(sorted(submenuDict.iteritems())):
            for subMenuName, snippet_tuple in iter(
                    sorted(submenuDict.iteritems())):
                action = groupMenu.addAction(subMenuName)

                actionKey = menuName.strip() + ' ' + subMenuName.strip(
                )  # for lookup int he self.snippetDictionary
                # self.snippetDictionary[actionKey] = snippetText
                self.snippetDictionary[actionKey] = snippet_tuple

                self.actions[actionKey] = action
                # self.__ui.connect(action, SIGNAL("triggered()"), self.snippetMapper, SLOT("map()"))
                action.triggered.connect(self.snippetMapper.map)
                self.snippetMapper.setMapping(action, actionKey)

        self.actions["Skip Comments In Python Snippets"] = QAction(
            "Skip Comments In Python Snippets",
            self,
            shortcut="",
            statusTip="Skip Comments In Python Snippets")
        self.actions["Skip Comments In Python Snippets"].setCheckable(True)
        flag = self.configuration.setting("SkipCommentsInPythonSnippets")
        self.skipCommentsInPythonSnippets(flag)
        self.actions["Skip Comments In Python Snippets"].setChecked(flag)

        # self.connect(self.actions["Skip Comments In Python Snippets"], SIGNAL('triggered(bool)'),
        #              self.skipCommentsInPythonSnippets)

        self.actions["Skip Comments In Python Snippets"].triggered.connect(
            self.skipCommentsInPythonSnippets)

        self.cc3dPythonMenu.addSeparator()
        # ---------------------------------------
        self.cc3dPythonMenu.addAction(
            self.actions["Skip Comments In Python Snippets"])
    def __initActions(self):
        """
        Private method to initialize the actions.
        """
        # lists begining of action names which will be grouped 



        self.snippetDictionary = {}
        psmp = SnippetMenuParser()
        snippetFilePath = os.path.abspath(
            os.path.join(os.path.dirname(__file__), 'CC3DPythonHelper/Snippets.py.template'))

        psmp.readSnippetMenu(snippetFilePath)

        snippetMenuDict = psmp.getSnippetMenuDict()
        # print 'snippet menu dict = ',snippetMenuDict



        for menuName, submenuDict in iter(sorted(snippetMenuDict.iteritems())):
            print 'menuName=', menuName

            groupMenu = self.cc3dPythonMenu.addMenu(menuName)

            # for subMenuName, snippetText in iter(sorted(submenuDict.iteritems())):
            for subMenuName, snippet_tuple in iter(sorted(submenuDict.iteritems())):
                action = groupMenu.addAction(subMenuName)

                actionKey = menuName.strip() + ' ' + subMenuName.strip()  # for lookup int he self.snippetDictionary
                # self.snippetDictionary[actionKey] = snippetText
                self.snippetDictionary[actionKey] = snippet_tuple

                self.actions[actionKey] = action
                # self.__ui.connect(action, SIGNAL("triggered()"), self.snippetMapper, SLOT("map()"))
                action.triggered.connect(self.snippetMapper.map)
                self.snippetMapper.setMapping(action, actionKey)

        self.actions["Skip Comments In Python Snippets"] = QAction("Skip Comments In Python Snippets", self,
                                                                         shortcut="",
                                                                         statusTip="Skip Comments In Python Snippets")
        self.actions["Skip Comments In Python Snippets"].setCheckable(True)
        flag = self.configuration.setting("SkipCommentsInPythonSnippets")
        self.skipCommentsInPythonSnippets(flag)
        self.actions["Skip Comments In Python Snippets"].setChecked(flag)

        # self.connect(self.actions["Skip Comments In Python Snippets"], SIGNAL('triggered(bool)'),
        #              self.skipCommentsInPythonSnippets)

        self.actions["Skip Comments In Python Snippets"].triggered.connect(self.skipCommentsInPythonSnippets)


        self.cc3dPythonMenu.addSeparator()
        # ---------------------------------------
        self.cc3dPythonMenu.addAction(self.actions["Skip Comments In Python Snippets"])