Chaos Leagues est désormais compatible avec l'extension FastNews.kiwi disponible pour votre navigateur. Avec cette extension, vérifiez s'il y a des nouveaux sujets sur ce forum en un clic depuis n'importe quelle page !Cliquez ici pour en savoir plus.
Posté le: Lun 9 Oct - 15:07 (2017) Sujet du message: A differen “Drag and Drop” images in Tkinter (Python 3.x)
I'm trying to make it possible for my program's user to drag an image from a widget and drop it in another without removing the image from its first position.
I thought on using a TopLevel for this. Upon a click+drag event, a TopLevel, containing the same image, would pop up right above the clicked image on the event.x and event.y position. Then it would change its position along with the mouse and only upon ButtonRelease-1 the TopLevel would be destroyed.
If the Button Release event was triggered on the master x and y coordinates corresponding to where is my other widget (in the case, a canvas), then it would trigger a canvas.create_image() using the event.x and event.y.
The problems I'm facing are:
Only 1 TopLevel should appear at once, but I had no success limiting it. Several windows overlap as I click and drag the mouse. I can't make Toplevel.geometry use the bound event's x and y positions. How to make the Toplevel display the same image as the user clicked, without magic numbers and variables?
I didn't find the right solution from the internet. References: