mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-15 17:20:07 +01:00
Use a global wx.DataFormat
This commit is contained in:
@@ -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 = """<html><body>
|
||||
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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user