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
| def addition() :
a=c.get()
b=d.get()
somme= a+b
def soustraction() :
a=c.get()
b=d.get()
soustr= a-b
def multiplication() :
a=c.get()
b=d.get()
multip= a*b
def division() :
a=c.get()
b=d.get()
divis= a/b
def point():
print('.')
from tkinter import*
fenetre= Tk()
fenetre.title("Calculatrice")
fenetre.geometry('320x276')
def callback(number):
global valeur
valeur.set(number)
frame1= Frame(fenetre,bg='grey')
frame1.grid(row=0,column=0,)
valeur=IntVar()
valeur.set(0)
entree3= Entry(frame1,width=7,textvariable=valeur,font=("Impact", 16))
entree3.grid(row=0,column =0)
Bouton0= Button(frame1,bg='grey',text="0",font=('Impact',16),width=7,command=lambda: callback(0))
Bouton0.grid(row=4,column=1)
Bouton1= Button(frame1,bg='grey',text="1",font=('Impact',16),width=7,command=lambda: callback(1))
Bouton1.grid(row=3,column=0)
Bouton2= Button(frame1,bg='grey',text="2",font=('Impact',16),width=7,command=lambda: callback(2))
Bouton2.grid(row=3,column=1)
Bouton3= Button(frame1,bg='grey',text="3",font=('Impact',16),width=7,command=lambda: callback(3))
Bouton3.grid(row=3,column=2)
Bouton4= Button(frame1,bg='grey',text="4",font=('Impact',16),width=7,command=lambda: callback(4))
Bouton4.grid(row=2,column=0)
Bouton5= Button(frame1,bg='grey',text="5",font=('Impact',16),width=7,command=lambda: callback(5))
Bouton5.grid(row=2,column=1)
Bouton6= Button(frame1,bg='grey',text="6",font=('Impact',16),width=7,command=lambda: callback(6))
Bouton6.grid(row=2,column=2)
Bouton7= Button(frame1,bg='grey',text="7",font=('Impact',16),width=7,command=lambda: callback(7))
Bouton7.grid(row=1,column=0)
Bouton8= Button(frame1,bg='grey',text="8",font=('Impact',16),width=7,command=lambda: callback(8))
Bouton8.grid(row=1,column=1)
Bouton9= Button(frame1,bg='grey',text="9",font=('Impact',16),width=7,command=lambda: callback(9))
Bouton9.grid(row=1,column=2)
Boutonpoint= Button(frame1,bg='grey',text=",",font=('Impact',16),width=7,command=point)
Boutonpoint.grid(row=5,column=2)
Boutonplus= Button(frame1,bg='grey',text="+",font=('Impact',16),width=7,command=addition)
Boutonplus.grid(row=4,column=4)
Boutonmoins= Button(frame1,bg='grey',text="-",font=('Impact',16),width=7,command=soustraction)
Boutonmoins.grid(row=3,column=4)
Boutonfois= Button(frame1,bg='grey',text="*",font=('Impact',16),width=7,command=multiplication)
Boutonfois.grid(row=2,column=4)
Boutondivi= Button(frame1,bg='grey',text="/",font=('Impact',16),width=7,command=division)
Boutondivi.grid(row=1,column=4)
Boutonclear= Button(frame1,bg='grey',text="Clear",font=('Impact',16),width=7,command=point)
Boutonclear.grid(row=5,column=0)
Boutonegal= Button(frame1,bg='grey',text="=",font=('Impact',16),width=7,command=point)
Boutonegal.grid(row=5,column=4)
Boutonvide= Button(frame1,bg='grey',text="",font=('Impact',16),width=7)
Boutonvide.grid(row=4,column=0)
Boutonvide= Button(frame1,bg='grey',text="",font=('Impact',16),width=7)
Boutonvide.grid(row=4,column=2)
Boutonvide= Button(frame1,bg='grey',text="",font=('Impact',16),width=7)
Boutonvide.grid(row=5,column=1)
Boutonquit=Button(frame1,bg='grey',text='Fermer',font=('Impact',16),width=7,command=fenetre.quit)
Boutonquit.grid(row=0,column=4)
fenetre.mainloop()
fenetre.destroy() |
Partager