I am having issues with traversing across siblings in a TreeCtrl. For example, pretend there is a tree:
Root
- Cat
- Dog
- Lion
I want an operation OnShiftDown, applied to Cat once, make the tree look like this, with Cat below Dog:
Root
- Dog
- Cat
- Lion
I know how to make OnShiftDown make the tree look like this, with Cat as Dog’s child, but it’s not what I want:
Root
- Dog
– Cat - Lion
I am unable to make a node simply cross its sibling without becoming the sibling’s child. My complete logic code is attached, but the methods in question are as follows:
def OnShiftDown(self, e):
“”" Bound to Ctrl-D “”"
old = self.tree.GetSelection()
target = self.tree.GetItemParent(old)
if not target.IsOk():
return
new = self.tree.AppendItem(parent = target, text = self.tree.GetItemText(old), data = self.tree.GetItemData(old))
self.tree.SelectItem
(new)
self.DeleteNode(old)
def OnShiftUp(self, e):
""" Bound to Ctrl-U """
old = self.tree.GetSelection()
target = self.tree.GetItemParent
(old)
if not target.IsOk():
return
new = self.tree.AppendItem(parent = target, text = self.tree.GetItemText(old), data = self.tree.GetItemData(old))
self.tree.SelectItem
(new)
self.DeleteNode(old)
I am unable to find any method that appends a node at the same level without making it the child of another node in the level. I just want to move nodes up and down, without changing their parents. Nodes in my tree (except for the root node) should not have children. This is quite an annoying problem, because making the node a child of another node is simple, but leaving it at sibling level is complicated - but I am probably missing something.
Thanks in advance,
Saketh
NotalonEditor.py (2.49 KB)