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
| class DragManager:
def add_dragable(self, widget):
c_echecs.tag_bind(widget, "<ButtonPress-1>", self.on_start)
c_echecs.tag_bind(widget, "<B1-Motion>", self.on_drag)
c_echecs.tag_bind(widget, "<ButtonRelease-1>", self.on_drop)
def on_start(self, event):
c_echecs.configure(cursor="hand2")
pass
def on_drag(self, event):
global dame_n1
pion_n1, cava_n1, fou_n1, tour_n1, dame_n1, roi_n1, pion_b1, cava_b1, fou_b1, tour_b1, dame_b1, roi_b1 = importation_pionsV1()
d_n = c_echecs.create_image(event.x, event.y, image=dame_n1)
pass
def on_drop(self, event):
global d_n
c_echecs.configure(cursor="")
for lig in range(8):
for col in range(8):
if (lig * 80) <= event.y <= ((lig + 1) * 80) and 40 + (col * 80) <= event.x <= 40 + ((col + 1) * 80):
global dame_n1
pion_n1, cava_n1, fou_n1, tour_n1, dame_n1, roi_n1, pion_b1, cava_b1, fou_b1, tour_b1, dame_b1, roi_b1 = importation_pionsV1()
d_n = c_echecs.create_image(80 + (col * 80), 40 + (lig * 80), image=dame_n1)
dragndrop = DragManager()
dragndrop.add_dragable(d_n) |
Partager