Environment
- wxPython 4.2.5 gtk3 (Phoenix) / wxWidgets 3.2.9
- Linux / GTK3
Summary
wx.dataview.DataViewCtrl drag-and-drop is non-functional on GTK from Python because
the SWIG bindings do not expose drop payload data in a usable form.
Bug 1: GetDataBuffer() returns opaque C pointer
In EVT_DATAVIEW_ITEM_DROP, event.GetDataBuffer() returns a raw SWIG void*
pointer (<Swig Object of type 'void *' at 0x...>) rather than a Python bytes
object. It is impossible to read the dragged data.
def on_drop(self, event):
buf = event.GetDataBuffer()
# buf is a void* — cannot call .decode(), bytes(), memoryview(), etc.
# No way to reconstruct what was dragged
Bug 2: GetDataObject() returns None in drop handler
Users also report event.GetDataObject() returns None inside the drop handler,
providing no alternative route to the data.
Bug 3 (possibly fixed in Phoenix): double-free on SetDataObject()
The original wxWidgets issue #16881 (closed "outdated" in 2017 with a redirect to
Phoenix) documented a crash when calling event.SetDataObject(obj) in
EVT_DATAVIEW_ITEM_BEGIN_DRAG on GTK because Python and C++ both attempt to free
the object. The workaround was obj.this.disown(). It is unclear whether Phoenix's
ownership model has resolved this.
Related
Impact
DataViewCtrl with PyDataViewModel would be a clean MVC alternative to wx.TreeCtrl
for tree UIs on GTK, but the broken DnD bindings make it unusable for any application
requiring drag-and-drop reordering on Linux.
Environment
Summary
wx.dataview.DataViewCtrldrag-and-drop is non-functional on GTK from Python becausethe SWIG bindings do not expose drop payload data in a usable form.
Bug 1:
GetDataBuffer()returns opaque C pointerIn
EVT_DATAVIEW_ITEM_DROP,event.GetDataBuffer()returns a raw SWIGvoid*pointer (
<Swig Object of type 'void *' at 0x...>) rather than a Pythonbytesobject. It is impossible to read the dragged data.
Bug 2:
GetDataObject()returnsNonein drop handlerUsers also report
event.GetDataObject()returnsNoneinside the drop handler,providing no alternative route to the data.
Bug 3 (possibly fixed in Phoenix): double-free on
SetDataObject()The original wxWidgets issue #16881 (closed "outdated" in 2017 with a redirect to
Phoenix) documented a crash when calling
event.SetDataObject(obj)inEVT_DATAVIEW_ITEM_BEGIN_DRAGon GTK because Python and C++ both attempt to freethe object. The workaround was
obj.this.disown(). It is unclear whether Phoenix'sownership model has resolved this.
Related
todo item, not a bug report
Impact
DataViewCtrlwithPyDataViewModelwould be a clean MVC alternative towx.TreeCtrlfor tree UIs on GTK, but the broken DnD bindings make it unusable for any application
requiring drag-and-drop reordering on Linux.