I want to use drag&drop in combination with wx.dataview.DataViewCtrl, so I started with trying to reorder rows using Drag&Drop. I was unable to find any examples how to do this correctly in wxpython, but anyhow, I managed to get it partially working (see attached samplecode).
Unfortunately, event.GetDataObject() always returns None in my on_drop function. Any pointers how to get the DataObject I assigned in on_begin_drag? What am I doing wrong?
This is not possible in Python (at least I think so).
Thus, I’m coming to the conclusion that this is a bug which renders Drag&Drop with DataViewCtrl unusable. If I call event.GetDataBuffer() in the handler function of an EVT_DATAVIEW_ITEM_DROP, I get <Swig Object of type ‘void *’ at 0x1a59b30>. Since that C pointer is basically useless in python (I think so at least), that function should return a proper Python buffer object. And, if I look at the docs for wx.Image, which also has a GetDataBuffer()-method, it states: “Returns a writable Python buffer object that is pointing at the RGB image data buffer inside the wx.Image.”
I my assumption correct? Should I open a trac ticket?
···
Am Dienstag, 24. Februar 2015 15:51:19 UTC+1 schrieb Jan H.:
I want to use drag&drop in combination with wx.dataview.DataViewCtrl, so I started with trying to reorder rows using Drag&Drop. I was unable to find any examples how to do this correctly in wxpython, but anyhow, I managed to get it partially working (see attached samplecode).
Unfortunately, event.GetDataObject() always returns None in my on_drop function. Any pointers how to get the DataObject I assigned in on_begin_drag? What am I doing wrong?
In Lines 892-893, they get the data like this:
> wxTextDataObject obj;
> obj.SetData( wxDF_UNICODETEXT, event.GetDataSize(),
event.GetDataBuffer() );
This is not possible in Python (at least I think so).
Thus, I'm coming to the conclusion that this is a bug which renders
Drag&Drop with DataViewCtrl unusable. If I call event.GetDataBuffer() in
the handler function of an EVT_DATAVIEW_ITEM_DROP, I get <Swig Object of
type 'void *' at 0x1a59b30>. Since that C pointer is basically useless
in python (I think so at least), that function should return a proper
Python buffer object. And, if I look at the docs for wx.Image, which
also has a GetDataBuffer()-method, it states: "Returns a writable Python
buffer object that is pointing at the RGB image data buffer inside the
wx.Image."
I my assumption correct? Should I open a trac ticket?
I think I need to do a little more tweaking in Phoenix to get those DnD related methods in the DataViewEvent working properly. I'll try to get to it soon, and will update one of the samples to show how to do it.