cpython
cpython copied to clipboard
Suggested change to dnd.py to better work with multiple top level windows.
I had issues with multiple windows. My initial widget and my destination widget were different top level windows. This solution worked well and I can't think of any reason it would break the existing code. Would be good to check if a valid widget first.
tested. ish...
--- dnd.py 2026-01-04 20:08:11.713697389 -0800
+++ ../dnd.py 2026-01-04 20:10:04.273009496 -0800
@@ -151,7 +151,7 @@
def on_motion(self, event):
x, y = event.x_root, event.y_root
- target_widget = self.initial_widget.winfo_containing(x, y)
+ target_widget = event.widget.winfo_toplevel().winfo_containing(x, y)
source = self.source
new_target = None
while target_widget is not None: