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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| #!/usr/bin/env python3
# -*- coding: utf-8 -*-
from tkinter import *
# on crée la fenêtre principale
fenetre = Tk()
def delete():
#print(canvas.grid_slaves(row, column))
for canvas in fenetre.grid_slaves():
if int(canvas.grid_info()["column"]) == 5:
canvas.grid_forget()
def click(event):
canvas.create_line(event.x, event.y, coords)
canvas.after(1000,canvas.delete)
#canvas_id = canvas.create_line(event.x, event.y, coords)
#canvas.after(1000, canvas.delete, canvas_id)
j = 1
while j < 10:
i=1
while i < 10:
canvas = "canvas" + str(i) + str(j)
canvas = Canvas(fenetre, bg="pale goldenrod")
canvas.grid(row=j, column=i, sticky=NW+SE)
if i == 5:
label = Label(canvas, bg="white", text="A SUPPRIMER", width=10, height=5, borderwidth=2, relief="solid")
else:
label = Label(canvas, bg="white", text="BLANC", width=10, height=5, borderwidth=2, relief="solid")
label.grid(row=j, column=i, sticky=NW+SE)
i=i+1
j=j+1
# on ajoute un bouton quitter
button1 = Button(fenetre, text='Delete', width=14, height=4, command=delete)
button1.grid(row =0, column =0, padx =0, pady =0)
button1.bind('<B1-Motion>',delete)
# on lance la boucle principale
fenetre.mainloop() |
Partager