1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| from tkinter import *
carrebleu = [[11,94], [53,94], [11,207], [53,207]]
carrebleu2 = [[438,92], [478,92], [438,206], [478,206]]
x = 240
y = 145
r = 8
def souris(event):
if (carrebleu2[0][0] < event.x < carrebleu2[1][0] and carrebleu2[0][1] < event.y < carrebleu2[2][1]) or (carrebleu[0][0] < event.x < carrebleu[1][0] and carrebleu[0][1] < event.y < carrebleu[2][1]):
print("Vous etes sur la zone invisible")
def move(event):
x = fenetre_plateau.canvasx(event.x)
y = fenetre_plateau.canvasy(event.y)
fenetre_plateau.coords(pion, x-10, y-10, x+10, y+10)
root2 = Tk()
fenetre_plateau=Canvas(root2, width="487", height="315")
photo = PhotoImage(file="mapcouper.gif")
fenetre_plateau.create_image(243.5, 157.5, image=photo)
pion = fenetre_plateau.create_oval(210, 210, 230, 230, fill='red')
fenetre_plateau.pack()
root2.bind('<Motion>', souris)
root2.bind('<1>', move)
root2.mainloop() |
Partager