I have a wxPython program where I want to be able to drag groups of controls around to reorder them.  Each group of controls is on a panel, and I want the panel object to handle the drag-and-drop.
Currently it works if you click and drag on the panel itself, but it doesn't work if you click on any control inside the panel.  This is because the wx.EVT_LEFT_DOWN event that I am using to trigger the drag is not a command event, so is not propagated up to the parent panel.
The only way I can think of to get round this is to bind that event to the panel's handler for every control on the panel.
This does not seem very elegant to me - either I have to explicitly do it when I create each child event, which breaks encapsulation, or the panel recurses through the child controls and does the binding - this seems dangerous, since the individual controls may already be using that event for other purposes.  Ideally I would like the controls on the panel to not need to know anything about the DnD.
Does anyone know of any alternative solutions?  Are there any command events that I could use to initiate dragging?  Or anything else I haven't thought of?
IMO the best way is, Panel should bind to control's wx.EVT_LEFT_DOWN and drag only when special key combination e.g. cntrl-alt-d are pressed
Panel can do it recursively or have a function in Panel, addControl and only such control will be hooked.
Your point that "individual controls may already be using that event for other purposes" is not valid because either you can use that event for dragging or not, you can't have both way.
If you want drag on control to be used as drag of whole group, then you MUST override such event, but with doing dragging only inspecial key combination or modes you can let child control have their behaviour too.
wxPython: Handling drag-and-drop in a parent object - problem with event propagation