当前位置: 首页>>代码示例>>Python>>正文


Python Manager.register方法代码示例

本文整理汇总了Python中component.Manager.register方法的典型用法代码示例。如果您正苦于以下问题:Python Manager.register方法的具体用法?Python Manager.register怎么用?Python Manager.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在component.Manager的用法示例。


在下文中一共展示了Manager.register方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: AddNode

# 需要导入模块: from component import Manager [as 别名]
# 或者: from component.Manager import register [as 别名]
 def AddNode(self, parent, node):
     # Append tree item
     try:
         comp = Manager.getNodeComp(node, None)
         className = comp.klass
     except:
         className = node.getAttribute('class')
         # Try to create some generic component on-the-fly
         attributes = []
         isContainer = False
         for n in node.childNodes:
             if is_object(n):
                 isContainer = True
             elif n.nodeType == node.ELEMENT_NODE and not n.tagName in attributes:
                 attributes.append(n.tagName)
         if isContainer:
             comp = Container(className, 'unknown', attributes)
         else:
             comp = Component(className, 'unknown', attributes)
         Manager.register(comp)
         wx.LogWarning('Unknown component class "%s", registered as generic' % className)
     item = self.AppendItem(parent, comp.getTreeText(node), 
                            image=comp.getTreeImageId(node),
                            data=wx.TreeItemData(node))
     self.SetItemStyle(item, node)
     # Try to find children objects
     if comp.isContainer():
         for n in filter(is_object, node.childNodes):
             self.AddNode(item, comp.getTreeNode(n))
开发者ID:AceZOfZSpades,项目名称:RankPanda,代码行数:31,代码来源:XMLTree.py

示例2: AddNode

# 需要导入模块: from component import Manager [as 别名]
# 或者: from component.Manager import register [as 别名]
    def AddNode(self, parent, node):
        # Append tree item
        try:
            comp = Manager.getNodeComp(node, None)
            className = comp.klass
        except:
            className = node.getAttribute("class")
            # Try to create some generic component on-the-fly
            attributes = []
            isContainer = False
            for n in node.childNodes:
                if is_element(n):
                    isContainer = True
                elif n.nodeType == node.ELEMENT_NODE and not n.tagName in attributes:
                    attributes.append(n.tagName)
            if isContainer:
                comp = Container(className, "unknown", attributes)
            else:
                comp = Component(className, "unknown", attributes)
            Manager.register(comp)
            wx.LogWarning('Unknown component class "%s", registered as generic' % className)
        item = self.AppendItem(
            parent, comp.getTreeText(node), image=comp.getTreeImageId(node), data=wx.TreeItemData(node)
        )
        self.SetItemStyle(item, node)
        # Try to find children objects
        if comp.isContainer():
            for n in filter(is_object, node.childNodes):
                self.AddNode(item, comp.getTreeNode(n))
        elif node.nodeType == node.COMMENT_NODE:
            if node.data and node.data[0] == "%" and g.conf.allowExec != "no":
                if g.conf.allowExec == "ask" and Model.allowExec is None:
                    say = wx.MessageBox(
                        """This file contains executable comment directives. \
Allow to execute?""",
                        "Warning",
                        wx.ICON_EXCLAMATION | wx.YES_NO,
                    )
                    if say == wx.YES:
                        Model.allowExec = True
                    else:
                        Model.allowExec = False
                if g.conf.allowExec == "yes" or Model.allowExec:
                    code = node.data[1:]  # skip '%'
                    self.ExecCode(code)
开发者ID:apetcho,项目名称:wxPython-2,代码行数:47,代码来源:XMLTree.py

示例3: OnInit

# 需要导入模块: from component import Manager [as 别名]
# 或者: from component.Manager import register [as 别名]
    def OnInit(self):
        # Check version
        if wx.VERSION[:3] < MinWxVersion:
            wx.LogWarning('''\
This version of XRCed may not work correctly on your version of wxWidgets. \
Please upgrade wxWidgets to %d.%d.%d or higher.''' % MinWxVersion)

        g.undoMan = undo.UndoManager()
        Manager.init()

        parser = OptionParser(prog=progname, 
                              version='%s version %s' % (ProgName, version),
                              usage='%prog [options] [XRC file]')
        parser.add_option('-d', '--debug', action='store_true',
                          help='add Debug command to Help menu')
        parser.add_option('-m', '--meta', action='store_true',
                          dest = 'meta',
                          help='activate meta-components')
        parser.add_option('-v', '--verbose', action='store_true',
                          help='verbose messages')

        # Process command-line arguments
        options, args = parser.parse_args()
        if options.debug:
            set_debug(True)
        if options.verbose:
            set_verbose(True)
        if options.meta:
            g.useMeta = True
            import meta
            Manager.register(meta.Component)
            Manager.setMenu(meta.Component, 'TOP_LEVEL', 'component', 'component plugin')
            
        self.SetAppName(progname)

        self.ReadConfig()
        
        # Add handlers
        wx.FileSystem.AddHandler(wx.MemoryFSHandler())
        self.toolArtProvider = view.ToolArtProvider()
        wx.ArtProvider.Push(self.toolArtProvider)

        # Load standard plugins first
        plugin.load_plugins(os.path.join(g.basePath, 'plugins'))
        # ... and then from user-defined dirs
        plugin.load_plugins_from_dirs()

        # Setup MVP
        view.create_view()
        Presenter.init()
        Listener.Install(view.frame, view.tree, view.panel,
                         view.toolFrame, view.testWin)

        if args:
            path = args[0]
            # Change current directory
            dir = os.path.dirname(path)
            if dir:
                os.chdir(dir)
                path = os.path.basename(path)
            if os.path.isfile(path):
                Presenter.open(path)
            else:
                # Future name
                Presenter.path = path
                # Force update title
                Presenter.setModified(False)
        view.frame.Show()
        if not g.useAUI:
            if not g.conf.embedPanel:
                view.frame.miniFrame.Show()
            if g.conf.showToolPanel:
                Listener.toolFrame.Show()

        return True
开发者ID:RupertTheSlim,项目名称:Programming,代码行数:77,代码来源:xrced.py


注:本文中的component.Manager.register方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。