Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def shift_up(event):
- tree = event.widget
- cur_item = tree.focus()
- prev_item = tree.prev(cur_item)
- _parent = super(Treeview, self).parent(cur_item)
- if self.root_selection < cur_item:
- tree.selection_remove(cur_item)
- if prev_item:
- _children = tree.get_children(prev_item)
- if _children and tree.item(prev_item)['open']:
- self.select_tail(prev_item)
- prev_item = tree.focus()
- tree.selection_add(prev_item)
- tree.focus(prev_item)
- elif _parent:
- tree.selection_add(_parent)
- tree.focus(_parent)
- return 'break'
- self.bind('<Shift-Up>', lambda e: shift_up(e))
- def shift_down(event):
- tree = event.widget
- cur_item = tree.focus()
- next_item = tree.next(cur_item)
- children = tree.get_children(cur_item)
- _parent = super(Treeview, self).parent(cur_item)
- if self.root_selection > cur_item:
- tree.selection_remove(cur_item)
- if children and tree.item(cur_item)['open']:
- cur_item = children[0]
- tree.selection_add(cur_item)
- tree.focus(cur_item)
- elif next_item:
- tree.selection_add(next_item)
- tree.focus(next_item)
- else:
- while not tree.next(_parent):
- _parent = super(Treeview, self).parent(_parent)
- if not _parent:
- tree.focus(cur_item)
- return
- cur_item = tree.next(_parent)
- tree.selection_add(cur_item)
- tree.focus(cur_item)
- return 'break'
- self.bind('<Shift-Down>', lambda e: shift_down(e))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement