Canvas

Dessiner
Architecture
Ecrire
fonction
Image

Evenement

Clavier
Cliquer
drag and drop
after
lambda
timer configure

Widget

Bouton
Label
Entry
Bouton Radio
Liste déroulante

drag and drop

from tkinter import *
 
def Clic(event):
    global DETECTION_CLIC_SUR_OBJET
    DETECTION_CLIC_SUR_OBJET = 1
 
def Drag(event):
    X = event.x
    Y = event.y
    if DETECTION_CLIC_SUR_OBJET == 1:
        Canevas.coords(img,X,Y)
def Relache(event):
    DETECTION_CLIC_SUR_OBJET = 0
 
DETECTION_CLIC_SUR_OBJET = FALSE
 
Mafenetre = Tk()
Mafenetre.title("Drag and drop")
 
Canevas = Canvas(Mafenetre,width=800,height=700,bg ='white')
fichier=PhotoImage(file='1.gif')
img=Canevas.create_image(90,90,image=fichier,tag="image")
 
Canevas.pack(padx=10,pady=10)
 
Canevas.tag_bind("image","<Button-1>",Clic)
Canevas.bind('<B1-Motion>',Drag)
Canevas.bind('<ButtonRelease-1>',Relache)
Mafenetre.mainloop()