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 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| from tkinter import *
Mafenetre = Tk()
Mafenetre.geometry('700x700+0+0')
Mafenetre.title('Damier')
Largeur = 598
Hauteur = 598
Canevas = Canvas(Mafenetre, width = Largeur, height =Hauteur, bg ='white')
Canevas.pack(padx =5, pady=5)
#Création du damier
a=-120
while a<600:
a=a+120
k=0
while k<600:
k=k+120
Carre = Canevas.create_rectangle(-120+k,0+a,-60+k,60+a,fill='black')
a=-120
while a<600:
a=a+120
k=0
while k<600:
k=k+120
Carre = Canevas.create_rectangle(-60+k,60+a,0+k,120+a,fill='black')
#les pions marrons
a=-120
while a<120:
a=a+120
k=0
while k<600:
k=k+120
Carre = Canevas.create_oval(-120+k,0+a,-60+k,60+a,fill='brown')
a=240
while a<600:
a=a+120
k=0
while k<600:
k=k+120
Carre = Canevas.create_oval(-120+k,0+a,-60+k,60+a,fill='purple')
a=-120
while a<60:
a=a+120
k=0
while k<600:
k=k+120
Carre = Canevas.create_oval(-60+k,60+a,0+k,120+a,fill='brown')
a=240
while a<600:
a=a+120
k=0
while k<600:
k=k+120
Carre = Canevas.create_oval(-60+k,60+a,0+k,120+a,fill='purple')
Mafenetre.mainloop() |
Partager