This is a mixin class that can be used to easily implement dragging and dropping of tree items. It can be mixed in with wx.TreeCtrl, wx.gizmos.TreeListCtrl, or wx.lib.customtree.CustomTreeCtrl.
To use it derive a new class from this class and one of the tree controls, e.g.:
class MyTree(DragAndDrop, wx.TreeCtrl):
# Other code here
You must implement OnDrop. OnDrop is called when the user has dropped an item on top of another item. It’s up to you to decide how to handle the drop. If you are using this mixin together with the VirtualTree mixin, it makes sense to rearrange your underlying data and then call RefreshItems to let the virtual tree refresh itself.
wx.lib.mixins.treemixin.TreeAPIHarmonizer
, wx.lib.mixins.treemixin.TreeHelper
Initialize self. See help(type(self)) for accurate signature. |
|
This function must be overloaded in the derived class. |
|
DragAndDrop
(TreeAPIHarmonizer, TreeHelper)¶This is a mixin class that can be used to easily implement dragging and dropping of tree items. It can be mixed in with wx.TreeCtrl, wx.gizmos.TreeListCtrl, or wx.lib.customtree.CustomTreeCtrl.
To use it derive a new class from this class and one of the tree controls, e.g.:
class MyTree(DragAndDrop, wx.TreeCtrl):
# Other code here
You must implement OnDrop. OnDrop is called when the user has dropped an item on top of another item. It’s up to you to decide how to handle the drop. If you are using this mixin together with the VirtualTree mixin, it makes sense to rearrange your underlying data and then call RefreshItems to let the virtual tree refresh itself.
__init__
(self, *args, **kwargs)¶Initialize self. See help(type(self)) for accurate signature.
IsValidDragItem
(self, dragItem)¶IsValidDropTarget
(self, dropTarget)¶OnBeginDrag
(self, event)¶OnDragging
(self, event)¶OnDrop
(self, dropItem, dragItem)¶This function must be overloaded in the derived class. dragItem is the item being dragged by the user. dropItem is the item dragItem is dropped upon. If the user doesn’t drop dragItem on another item, dropItem equals the (hidden) root item of the tree control.
OnEndDrag
(self, event)¶ResetCursor
(self)¶SetCursorToDragging
(self)¶SetCursorToDroppingImpossible
(self)¶StartDragging
(self)¶StopDragging
(self)¶