Advertisement
Uno-Dan

Copy Function

Mar 11th, 2020
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1.     def copy(self):
  2.         def get_descendants(_node):
  3.             descendants = []
  4.  
  5.             _children = self.get_children(_node)
  6.             for _child in _children:
  7.                 descendants.append(_child)
  8.                 _nodes = self.get_children(_child)
  9.                 if _nodes:
  10.                     descendants += self.get_descendants(_child)
  11.  
  12.             return descendants
  13.  
  14.         self.was_cut = False
  15.         self.tags_remove_all('copy', 'selected')
  16.         self.refresh_tags()
  17.  
  18.         self.popup.enable_items(['paste'])
  19.         self.pointer_x, self.pointer_y = self.winfo_toplevel().winfo_pointerxy()
  20.  
  21.         items = []
  22.         selections = sorted(list(self.selection()))
  23.         for node in selections:
  24.             item = self.item(node)
  25.             _type = item['values'][0]
  26.             _open = item['open']
  27.             items.append(node)
  28.  
  29.             if not _open and _type == 'Menu':
  30.                 items += get_descendants(node)
  31.  
  32.         for item in items:
  33.             self.tags_add(item, ['copy', 'selected'])
  34.             self.tags_remove(item, ['odd', 'even'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement