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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
| from tkinter import*
import webbrowser
#Quelles touches le personnage va utiliser pour se déplacer
def Clavier(event):
global X,Y
touche = event.char
if touche == 'a':
X -= 20
if touche == 's':
Y += 20
if touche == 'd':
X += 20
if touche == 'w':
Y -= 20
formee.coords(personnage,X -10, Y -10, X +10, Y +10)
def tomber():
global dx, dy
canvas.move(rectangle1,dx,dy)
fen.after(40,tomber)
dx=0
dy=5
def Commencer():
u=Toplevel(fen)
X = 400
Y = 680
Largeur =800
Hauteur = 700
formee = Canvas(u, width = Largeur, height =Hauteur, bg ='#b5b0a1')
personnage = formee.create_rectangle(X-10,Y-10,X+10,Y+10,width=2,fill='#59191f')
formee.focus_set()
formee.bind('<Key>',Clavier)
formee.pack(padx =5, pady =5)
canvas = Canvas(u,width = 500, height = 400 , bd=0, bg="white")
canvas.pack(padx=10,pady=10)
rectangle1 = canvas.create_rectangle(80,80,30,30)
deplacement()
#renvoie vers une page web
def crédit():
webbrowser.open_new("https://writer.zoho.eu/writer/open/unoso934899ca0a2649e19fa3bc7b3de91b02")
def quitter():
fen.destroy()
def les_levels():
t=Toplevel(fen)
t.geometry("720x480")
t.title("choix niveau")
t.config(bg="#4671C6")
frameu = Frame(t, bg="white")
label_titre2= Label(frameu, text="Choix de niveaux", font=("Helvetica", 30), bg="#4671C6", fg="#A4C9FF")
label_titre2.pack()
niveau1= Button(frameu, text="Niveaux 1 à 20", font=("Helvetica", 20), bg="#4065A4", fg="#A4C9FF",command=Commencer)
niveau1.pack(fill=X)
niveau2= Button(frameu, text="Niveaux 20 à 40", font=("Helvetica", 20), bg="#4065A4", fg="#A4C9FF",command=Commencer)
niveau2.pack(fill=X)
niveau3= Button(frameu, text="Niveau 40 à 60", font=("Helvetica", 20), bg="#4065A4", fg="#A4C9FF",command=Commencer)
niveau3.pack(fill=X)
niveau3= Button(frameu, text="Niveau 60 à 80", font=("Helvetica", 20), bg="#4065A4", fg="#A4C9FF",command=Commencer)
niveau3.pack(fill=X)
niveau3= Button(frameu, text="Niveau 80 à 100", font=("Helvetica", 20), bg="#4065A4", fg="#A4C9FF",command=Commencer)
niveau3.pack(fill=X)
frameu.grid(row=1, column=0, sticky=W)
frameu.pack(expand=YES)
t.mainloop()
fen = Tk()
fen.title("mathématique")
fen.geometry("1080x720")
fen.config(bg="#4671C6")
fen.minsize(720, 480)
frame = Frame(fen, bg="#4671C6")
#le logo du menu principal
width= 360
height= 300
image= PhotoImage(file="mathematics.png").zoom(35).subsample(32)
canvas = Canvas(frame, width=width, height=height, bg="#4671C6", bd=0, highlightthickness=0 )
canvas.create_image(width/2, height/2, image=image)
canvas.grid(row=0, column=0, sticky=W)
framedroite = Frame(frame, bg="white")
label_titre= Label(framedroite, text="Mathematic super training", font=("Helvetica", 30), bg="#4671C6", fg="#A4C9FF")
label_titre.pack()
entré_boutton= Button(framedroite, text="Commencer", font=("Helvetica", 20), bg="#4065A4", fg="#A4C9FF", command=Commencer)
entré_boutton.pack(fill=X)
entré_boutton= Button(framedroite, text="Choix du niveau", font=("Helvetica", 20), bg="#4065A4", fg="#A4C9FF", command=les_levels)
entré_boutton.pack(fill=X)
entré_boutton= Button(framedroite, text="Crédit", font=("Helvetica", 20), bg="#4065A4", fg="#A4C9FF", command=crédit)
entré_boutton.pack(fill=X)
entré_boutton= Button(framedroite, text="Quitter", font=("Helvetica", 20), bg="#4065A4", fg="#A4C9FF",command=quitter)
entré_boutton.pack(fill=X)
framedroite.grid(row=1, column=0, sticky=W)
frame.pack(expand=YES)
fen.mainloop() |