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


Python component.Manager类代码示例

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


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

示例1: AddNode

 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,代码行数:29,代码来源:XMLTree.py

示例2: OnData

 def OnData(self, x, y, d):
     view.testWin.RemoveHighlightDT()
     self.onHL = self.left = False
     self.GetData()
     id = int(self.do.GetDataHere())
     d,other = self.WhereToDrop(x, y, d)
     if d != wx.DragNone and other:
         obj,item = other
         g.Presenter.setData(item)
         comp = Manager.findById(id)
         mouseState = wx.GetMouseState()
         forceSibling = mouseState.ControlDown()
         forceInsert = mouseState.ShiftDown()
         g.Presenter.updateCreateState(forceSibling, forceInsert)
         if not g.Presenter.checkCompatibility(comp):
             return wx.DragNone
         item = g.Presenter.create(comp)
         node = view.tree.GetPyData(item)
         parentItem = view.tree.GetItemParent(item)
         parentNode = view.tree.GetPyData(parentItem)
         parentComp = Manager.getNodeComp(parentNode)
         # If pos if not set by default and parent is not a sizer, set pos to
         # drop coordinates
         if 'pos' in comp.attributes and not comp.getAttribute(node, 'pos') \
                and parentComp.isContainer() and \
                not parentComp.isSizer():
             # Calc relative coords
             rect = view.testWin.FindObjectRect(parentItem)
             x -= rect[0].x
             y -= rect[0].y
             comp.addAttribute(node, 'pos', '%d,%d' % (x, y))
             g.Presenter.setData(item)
         view.frame.SetStatusText('Object created')
     return d
开发者ID:Einstein-NTE,项目名称:einstein,代码行数:34,代码来源:TestWin.py

示例3: FindObject

 def FindObject(self, item):
     tree = view.tree
     if not item or item == tree.root:
         return None
     if item == self.item: return self.object
     # Traverse tree until we reach the root  or the test object
     items = [item]
     while 1:
         item = tree.GetItemParent(item)
         if item == tree.root: return None # item outside if the test subtree
         elif item == self.item: break
         else: items.append(item)
     # Now traverse back, searching children
     obj = self.object
     comp = Manager.getNodeComp(tree.GetPyData(self.item))
     while items and obj:
         if not (isinstance(obj, wx.Window) or isinstance(obj, wx.Sizer)):
             return None
         parentItem = item
         item = items.pop()
         index = tree.ItemIndex(item)
         obj = comp.getChildObject(tree.GetPyData(parentItem), obj, index)
         node = tree.GetPyData(item)
         comp = Manager.getNodeComp(node)
     return obj
开发者ID:Einstein-NTE,项目名称:einstein,代码行数:25,代码来源:TestWin.py

示例4: paste

    def paste(self):
        success = success_node = False
        if wx.TheClipboard.IsOpened() or wx.TheClipboard.Open():
            try:
                data = wx.CustomDataObject("XRCED_elem")
                if wx.TheClipboard.IsSupported(data.GetFormat()):
                    try:
                        success = wx.TheClipboard.GetData(data)
                    except:
                        # there is a problem if XRCED_node is in clipboard
                        # but previous SetData was for XRCED
                        pass
                if not success:  # try other format
                    data = wx.CustomDataObject("XRCED_node")
                    if wx.TheClipboard.IsSupported(data.GetFormat()):
                        success_node = wx.TheClipboard.GetData(data)
            finally:
                wx.TheClipboard.Close()

        if not success and not success_node:
            wx.MessageBox("There is no data in the clipboard in the required format", "Error")
            return

        # XML representation of element or node value string
        data = cPickle.loads(data.GetData())
        implicit = None
        if success:
            if type(data) is list:
                node = Model.parseString(data[0])
                implicit = Model.parseString(data[1])
            else:
                node = Model.parseString(data)
        else:
            node = Model.dom.createComment(data)
        comp = Manager.getNodeComp(node)

        # Check compatibility
        if not self.checkCompatibility(comp):
            node.unlink()
            return

        item = view.tree.GetSelection()
        if item and not self.applied:
            self.update(item)

        item = self.create(comp, node)
        if implicit:  # copy parameters for implicit node if possible
            parentNode = view.tree.GetPyData(view.tree.GetItemParent(item))
            parentComp = Manager.getNodeComp(parentNode)
            if parentComp.requireImplicit(node) and parentComp.implicitKlass == implicit.getAttribute("class"):
                parentComp.copyImplicitAttributes(implicit, node.parentNode, parentComp)
            implicit.unlink()

        # Add children
        for n in filter(is_object, node.childNodes):
            view.tree.AddNode(item, comp.getTreeNode(n))
        self.setModified()
        return item
开发者ID:czxxjtu,项目名称:wxPython,代码行数:58,代码来源:presenter.py

示例5: createRef

 def createRef(self, ref, child=None):
     '''Create object_ref element node.'''
     if child is None:
         child = Model.createRefNode(ref)
     refNode = Model.findResource(ref)
     if refNode: 
         comp = Manager.getNodeComp(refNode)
     else:
         comp = Manager.getNodeComp(child)
     self.create(comp, child)
开发者ID:Bottersnike,项目名称:Everbot,代码行数:10,代码来源:presenter.py

示例6: createTestWin

 def createTestWin(self, item):
     TRACE('createTestWin')
     # Create a window with this resource
     node = view.tree.GetPyData(item)
     # Close old window, remember where it was
     comp = Manager.getNodeComp(node)
     # Create memory XML file
     elem = node.cloneNode(True)
     if not node.hasAttribute('name'):
         name = 'noname'
     else:
         name = node.getAttribute('name')
     elem.setAttribute('name', STD_NAME)
     Model.setTestElem(elem)
     Model.saveTestMemoryFile()
     xmlFlags = 0
     if not g.conf.useSubclassing:
         xmlFlags |= xrc.XRC_NO_SUBCLASSING
     # Use translations if encoding is not specified
     if not Model.dom.encoding:
         xmlFlags |= xrc.XRC_USE_LOCALE
     res = xrc.EmptyXmlResource(xmlFlags)
     xrc.XmlResource.Set(res)        # set as global
     # Init other handlers
     Manager.addXmlHandlers(res)
     Manager.preload(res)
     # Same module list
     res.Load('memory:test.xrc')
     object = None
     testWin = view.testWin
     try:
         try:
             frame, object = comp.makeTestWin(res, name)
             if not object:  # skip the rest
                 raise EOFError
             # Reset previous tree item and locate tool
             if testWin.item:
                 view.tree.SetItemBold(testWin.item, False)
             testWin.SetView(frame, object, item)
             testWin.Show()
             view.tree.SetItemBold(item, True)
         except EOFError:
             pass
         except NotImplementedError:
             wx.LogError('Test window not implemented for %s' % node.getAttribute('class'))
             logger.exception('error creating test view')
         except:
             logger.exception('error creating test view')
             wx.LogError('Error creating test view')
             if get_debug(): raise
     finally:
         # Cleanup
         res.Unload(TEST_FILE)
         xrc.XmlResource.Set(None)
         wx.MemoryFSHandler.RemoveFile(TEST_FILE)
开发者ID:blitzmann,项目名称:Pyfa-skel,代码行数:55,代码来源:presenter.py

示例7: setData

    def setData(self, item):
        '''Set data and view for current tree item.'''

        self.item = item
        if item == view.tree.root:
            TRACE('setData: root node')
            self.container = None
            self.comp = Manager.rootComponent
            self.panels = view.panel.SetData(self.container, self.comp, Model.mainNode)
        else:
            node = view.tree.GetPyData(item)
            if node.nodeType != node.COMMENT_NODE:
                TRACE('setData: %s', node.getAttribute('class'))
            self.comp = Manager.getNodeComp(node)
            parentItem = view.tree.GetItemParent(item)
            parentNode = view.tree.GetPyData(parentItem)
            if parentNode == Model.mainNode:
                self.container = Manager.rootComponent
            else:
                parentClass = parentNode.getAttribute('class')
                self.container = Manager.components[parentClass]
            self.panels = view.panel.SetData(self.container, self.comp, node)
        # Create new pending undo
        self.createUndoEdit(self.item)

        if view.testWin.IsShown():
            self.highlight(item)
开发者ID:Bottersnike,项目名称:Everbot,代码行数:27,代码来源:presenter.py

示例8: undo

 def undo(self):
     Presenter.unselect()
     # Updating DOM. Find parent node first
     parentItem = view.tree.ItemAtFullIndex(self.itemIndex[:-1])
     parentNode = view.tree.GetPyData(parentItem)
     parentComp = Manager.getNodeComp(parentNode)
     nextItem = view.tree.ItemAtFullIndex(self.itemIndex)
     if nextItem:
         nextNode = parentComp.getTreeOrImplicitNode(view.tree.GetPyData(nextItem))
     else:
         nextNode = None
     # Insert before next
     parentNode.insertBefore(self.node, nextNode)
     # Remember test window item
     if view.testWin.item is not None:
         testItemIndex = view.tree.ItemFullIndex(view.testWin.item)
     # Update tree and presenter
     view.tree.FlushSubtree(parentItem, parentNode)
     view.tree.SetFullState(self.state)
     # Restore test window item
     if view.testWin.item is not None:
         view.testWin.item = view.tree.ItemAtFullIndex(testItemIndex)
     item = view.tree.ItemAtFullIndex(self.itemIndex)
     view.tree.EnsureVisible(item)
     # This will generate events
     view.tree.SelectItem(item)
开发者ID:AceZOfZSpades,项目名称:RankPanda,代码行数:26,代码来源:undo.py

示例9: setData

    def setData(self, item):
        """Set data and view for current tree item."""

        self.item = item
        if item == view.tree.root:
            TRACE("setData: root node")
            self.container = None
            self.comp = Manager.rootComponent
            #            self.panels = []
            #            view.panel.Clear()
            self.panels = view.panel.SetData(self.container, self.comp, Model.mainNode)
        else:
            node = view.tree.GetPyData(item)
            TRACE("setData: %s", node.getAttribute("class"))
            self.comp = Manager.getNodeComp(node)
            parentItem = view.tree.GetItemParent(item)
            parentNode = view.tree.GetPyData(parentItem)
            if parentNode == Model.mainNode:
                self.container = Manager.rootComponent
            else:
                parentClass = parentNode.getAttribute("class")
                self.container = Manager.components[parentClass]
            self.panels = view.panel.SetData(self.container, self.comp, node)
        # Create new pending undo
        self.createUndoEdit(self.item)

        if view.testWin.IsShown():
            self.highlight(item)
开发者ID:czxxjtu,项目名称:wxPython-1,代码行数:28,代码来源:presenter.py

示例10: moveLeft

    def moveLeft(self):
        parentItem = view.tree.GetItemParent(self.item)
        grandParentItem = view.tree.GetItemParent(parentItem)
        parent = view.tree.GetPyData(parentItem)
        grandParent = view.tree.GetPyData(grandParentItem)
        if grandParent is Model.mainNode:
            grandParentComp = Manager.rootComponent
        else:
            grandParentComp = Manager.getNodeComp(grandParent)
        if not grandParentComp.canHaveChild(self.comp):
            wx.LogError('Incompatible parent/child: parent is %s, child is %s!' %
                        (grandParentComp.klass, self.comp.klass))
            return

        node = view.tree.GetPyData(self.item)
        nextItem = view.tree.GetNextSibling(parentItem)
        self.container.removeChild(parent, node)
        if nextItem:
            nextNode = view.tree.GetPyData(nextItem)
            grandParentComp.insertBefore(grandParent, node, nextNode)
        else:
            grandParentComp.appendChild(grandParent, node)
        index = view.tree.ItemFullIndex(self.item)
        self.flushSubtree(grandParentItem, grandParent)
        index.pop()
        index[-1] += 1
        self.item = view.tree.ItemAtFullIndex(index)
        self.setModified()
        view.tree.SelectItem(self.item)
开发者ID:Bottersnike,项目名称:Everbot,代码行数:29,代码来源:presenter.py

示例11: OnComponentReplace

 def OnComponentReplace(self, evt):
     '''Hadnler for creating new elements.'''
     comp = Manager.findById(evt.GetId() - ID.SHIFT)
     item = self.tree.GetSelection()
     index = self.tree.ItemFullIndex(item)
     oldComp = Presenter.comp
     oldNode = Presenter.replace(comp)
     g.undoMan.RegisterUndo(undo.UndoReplace(index, oldComp, oldNode))
开发者ID:e-johnson,项目名称:AndroidProject,代码行数:8,代码来源:listener.py

示例12: AddNode

    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,代码行数:45,代码来源:XMLTree.py

示例13: OnComponentCreate

 def OnComponentCreate(self, evt):
     '''Hadnler for creating new elements.'''
     comp = Manager.findById(evt.GetId())
     g.undoMan.RegisterUndo(undo.UndoGlobal()) # !!! TODO
     if comp.groups[0] == 'component':
         node = Model.createComponentNode('Component')
         Presenter.create(comp, node)
     else:
         Presenter.create(comp)
开发者ID:RupertTheSlim,项目名称:Programming,代码行数:9,代码来源:listener.py

示例14: createRef

 def createRef(self, ref, child=None):
     """Create object_ref element node."""
     if child is None:
         child = Model.createRefNode(ref)
     refNode = Model.findResource(ref)
     if not refNode:
         return None
     comp = Manager.getNodeComp(refNode)
     self.create(comp, child)
开发者ID:czxxjtu,项目名称:wxPython-1,代码行数:9,代码来源:presenter.py

示例15: OnComponentCreate

 def OnComponentCreate(self, evt):
     '''Hadnler for creating new elements.'''
     state = self.tree.GetFullState() # state just before
     comp = Manager.findById(evt.GetId())
     if comp.groups[0] == 'component':
         node = Model.createComponentNode('Component')
         item = Presenter.create(comp, node)
     else:
         item = Presenter.create(comp)
     itemIndex = self.tree.ItemFullIndex(item)
     g.undoMan.RegisterUndo(undo.UndoPasteCreate(itemIndex, state))
开发者ID:e-johnson,项目名称:AndroidProject,代码行数:11,代码来源:listener.py


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