-
Notifications
You must be signed in to change notification settings - Fork 558
Description
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 draggedBug 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
- wxWidgets issue #16881 (closed outdated, never fixed in Phoenix): wx.dataview.DataViewCtrl's Drag-and-Drop unusable in wxPython wxWidgets#16881
- wxPython Discuss thread (no resolution): https://discuss.wxpython.org/t/dataviewctrl-dataviewtreectrl-issue-on-gtk-with-drag-drop-any-workaround/27826
- Phoenix issue Add DnD in DataViewCtrl demo #309 ("Add DnD in DataViewCtrl demo") notes the binding gap but is a
todo item, not a bug report
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.