From 4ab028d7c3de1c551d53ea60a2c29f03b424b478 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 7 Jan 2021 14:52:34 -0800 Subject: [PATCH] Use a global wx.DataFormat --- demo/CustomDragAndDrop.py | 10 ++++++---- wx/lib/agw/flatnotebook.py | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/demo/CustomDragAndDrop.py b/demo/CustomDragAndDrop.py index 7759b77a..940469d1 100644 --- a/demo/CustomDragAndDrop.py +++ b/demo/CustomDragAndDrop.py @@ -3,6 +3,8 @@ import pickle import wx +CUSTOM_DATA_FORMAT = wx.DataFormat('org.wxpython.DoodleLines') + #---------------------------------------------------------------------- dragResultNames = { @@ -84,7 +86,7 @@ class DoodlePad(wx.Window): # create our own data format and use it in a # custom data object - ldata = wx.CustomDataObject("application.DoodleLines") + ldata = wx.CustomDataObject(CUSTOM_DATA_FORMAT) ldata.SetData(linesdata) # Also create a Bitmap version of the drawing @@ -127,7 +129,7 @@ class DoodleDropTarget(wx.DropTarget): self.dv = window # specify the type of data we will accept - self.data = wx.CustomDataObject("application.DoodleLines") + self.data = wx.CustomDataObject(CUSTOM_DATA_FORMAT) self.SetDataObject(self.data) self.SetDefaultAction(wx.DragMove) @@ -336,8 +338,8 @@ if __name__ == '__main__': overview = """ This demo shows Drag and Drop using a custom data type and a custom -data object. A type called "DoodleLines" is created and a Python -Pickle of a list is actually transferred in the drag and drop +data object. A type called "org.wxpython.DoodleLines" is created and +a Python Pickle of a list is actually transferred in the drag and drop operation. A second data object is also created containing a bitmap of the image diff --git a/wx/lib/agw/flatnotebook.py b/wx/lib/agw/flatnotebook.py index 81102d40..f5e5200b 100644 --- a/wx/lib/agw/flatnotebook.py +++ b/wx/lib/agw/flatnotebook.py @@ -1056,6 +1056,7 @@ class FNBDragInfo(object): # Simply Used To Handle The OnDrop() Method When Dragging And Dropping Between # Different FlatNotebooks. # ---------------------------------------------------------------------------- # +FNB_DataFormat = wx.DataFormat('FlatNotebook') class FNBDropTarget(wx.DropTarget): """ @@ -1074,7 +1075,7 @@ class FNBDropTarget(wx.DropTarget): wx.DropTarget.__init__(self) self._parent = parent - self._dataobject = wx.CustomDataObject(wx.DataFormat(six.u('FlatNotebook'))) + self._dataobject = wx.CustomDataObject(FNB_DataFormat) self.SetDataObject(self._dataobject) @@ -5836,7 +5837,7 @@ class PageContainer(wx.Panel): self._isdragging = True draginfo = FNBDragInfo(self, tabIdx) drginfo = pickle.dumps(draginfo) - dataobject = wx.CustomDataObject(wx.DataFormat(six.u('FlatNotebook'))) + dataobject = wx.CustomDataObject(FNB_DataFormat) dataobject.SetData(drginfo) dragSource = FNBDropSource(self) dragSource.SetData(dataobject)