本文整理汇总了Python中model.Model.createObjectNode方法的典型用法代码示例。如果您正苦于以下问题:Python Model.createObjectNode方法的具体用法?Python Model.createObjectNode怎么用?Python Model.createObjectNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Model
的用法示例。
在下文中一共展示了Model.createObjectNode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: appendChild
# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import createObjectNode [as 别名]
def appendChild(self, parentNode, node):
if self.requireImplicit(node):
elem = Model.createObjectNode(self.implicitKlass)
elem.appendChild(node)
parentNode.appendChild(elem)
else:
parentNode.appendChild(node)
示例2: replace
# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import createObjectNode [as 别名]
def replace(self, comp, node=None):
'''Replace DOM node by new or passed node. Return new item.'''
TRACE('replace')
if node is None:
node = Model.createObjectNode(comp.klass)
if not self.applied:
self.update(item)
data = wx.TreeItemData(node)
item = self.item
parentItem = view.tree.GetItemParent(item)
parentNode = view.tree.GetPyData(parentItem)
oldNode = view.tree.GetPyData(item)
self.container.replaceChild(parentNode, node, oldNode)
# Replace tree item: insert new, remove old
label = comp.getTreeText(node)
imageId = comp.getTreeImageId(node)
item = view.tree.InsertItem(parentItem, item, label, imageId, data=data)
view.tree.Delete(view.tree.GetPrevSibling(item))
self.item = item
# Add children
for n in filter(is_object, node.childNodes):
view.tree.AddNode(item, comp.getTreeNode(n))
view.tree.EnsureVisible(item)
# Update panel
view.tree.SelectItem(item)
self.setModified()
return oldNode
示例3: insertBefore
# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import createObjectNode [as 别名]
def insertBefore(self, parentNode, node, nextNode):
if self.requireImplicit(nextNode):
nextNode = nextNode.parentNode
if self.requireImplicit(node):
elem = Model.createObjectNode(self.implicitKlass)
elem.appendChild(node)
parentNode.insertBefore(elem, nextNode)
else:
parentNode.insertBefore(node, nextNode)
示例4: insertAfter
# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import createObjectNode [as 别名]
def insertAfter(self, parentNode, node, prevNode):
if self.requireImplicit(prevNode):
nextNode = prevNode.parentNode.nextSibling
else:
nextNode = prevNode.nextSibling
if self.requireImplicit(node):
elem = Model.createObjectNode(self.implicitKlass)
elem.appendChild(node)
parentNode.insertBefore(elem, nextNode)
else:
parentNode.insertBefore(node, nextNode)
示例5: create
# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import createObjectNode [as 别名]
def create(self, comp, child=None):
'''
Add DOM node as child or sibling depending on flags. Return new item.
If child is passed replace by existing data.
'''
if child is None:
child = Model.createObjectNode(comp.klass)
# Set default values
for k,v in comp.defaults.items():
comp.addAttribute(child, k, v)
data = wx.TreeItemData(child)
item = self.item
if not self.applied:
self.update(item)
if item == view.tree.root:
self.createSibling = False # can't create sibling of root
if self.createSibling:
parentItem = view.tree.GetItemParent(item)
parentNode = view.tree.GetPyData(parentItem)
else:
parentNode = view.tree.GetPyData(item)
label = comp.getTreeText(child)
imageId = comp.getTreeImageId(child)
if self.createSibling:
node = view.tree.GetPyData(item)
if self.insertBefore:
self.container.insertBefore(parentNode, child, node)
item = view.tree.InsertItemBefore(
parentItem, item, label, imageId, data=data)
else:
self.container.insertAfter(parentNode, child, node)
item = view.tree.InsertItem(
parentItem, item, label, imageId, data=data)
else:
if self.insertBefore and view.tree.ItemHasChildren(item):
nextNode = view.tree.GetPyData(view.tree.GetFirstChild(item)[0])
self.comp.insertBefore(parentNode, child, nextNode)
item = view.tree.PrependItem(item, label, imageId, data=data)
else:
self.comp.appendChild(parentNode, child)
item = view.tree.AppendItem(item, label, imageId, data=data)
view.tree.SetItemStyle(item, child)
view.tree.EnsureVisible(item)
view.tree.UnselectAll()
if view.testWin.IsShown():
view.testWin.isDirty = True
view.tree.SelectItem(item)
self.setModified()
return item
示例6: replaceChild
# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import createObjectNode [as 别名]
def replaceChild(self, parentNode, newNode, oldNode):
# Do similarly to Container for object child nodes
oldComp = Manager.getNodeComp(oldNode)
oldComp.copyAttributes(oldNode, newNode)
if oldComp.isContainer():
oldComp.copyObjects(oldNode, newNode)
# Special treatment for implicit nodes
if self.requireImplicit(oldNode):
implicitNode = oldNode.parentNode
if self.requireImplicit(newNode):
implicitNode.replaceChild(newNode, oldNode)
else:
parentNode.replaceChild(newNode, implicitNode)
else:
if self.requireImplicit(newNode):
elem = Model.createObjectNode(self.implicitKlass)
elem.appendChild(newNode)
parentNode.replaceChild(elem, oldNode)
else:
parentNode.replaceChild(newNode, oldNode)