Exemplo n.º 1
0
 def buildSubMenu(self, parent, logger):
     #levelsMenu = pymel.menuItem(l="%s <%s>" % (logger.name, levelsDict[logger.level]),p=parent, sm=True)
     self.buildLevelMenu(parent, logger)
     pymel.menuItem(d=1, p=parent)
     try:
         if logger.children:
             pymel.menuItem(l="Child Loggers:", p=parent, en=0)
             for item in logger.children:
                 subMenu = pymel.menuItem(l=item.name,
                                          sm=True,
                                          p=parent,
                                          tearOff=True,
                                          aob=True,
                                          pmo=True)
                 subMenu.setPostMenuCommand(
                     pymel.Callback(self.buildSubMenu,
                                    parent=subMenu,
                                    logger=item))
                 subMenu.setPostMenuCommandOnce(True)
     except:
         pass  # this logger has no children
     pymel.menuItem(d=1, p=parent)
     if logger.handlers:
         pymel.menuItem(l="Streams:", p=parent, en=0)
         for item in logger.handlers:
             levelsMenu = pymel.menuItem(
                 l="%s <%s>" %
                 (item.__class__.__name__, levelsDict[item.level]),
                 p=parent,
                 sm=True,
                 aob=True)
             self.buildLevelMenu(levelsMenu, item)
             pymel.menuItem(d=1, p=levelsMenu)
             pymel.menuItem(l="Set Formatter",
                            p=levelsMenu,
                            c=pymel.Callback(self.setFormatter, item))
             pymel.menuItem(l="Remove",
                            p=levelsMenu,
                            ob=True,
                            c=pymel.Callback(logger.removeHandler, item))
     pymel.menuItem(l="<New Stream...>",
                    p=parent,
                    c=lambda *x: self.addHandler(logger))
 def buildLevelMenu(self, parent, item):
     for level in logLevelNames:
         pymel.menuItem(p=parent, checkBox=levelsDict[item.level]==level, l=level, c=pymel.Callback(self.changeLevel, item, level))