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
| from tkinter import *
from PIL import Image, ImageTk
from tkinter.messagebox import *
tref=[0,36671014,87076785,80614169,59006969,47054466,61566939]
tprix=[0,0.20,0.20,0.10,0.10,0.20,4.00]
soust=[]
tnb=[0,0,0,0,0,0,0]
t=[]
obj=[]
nobj=[]
timg=["","chevillefrap.jpg","molly.png","cheville.jpg","boulon.jpg","vis.jpg","pince.jpg"]
tproduit=["","Cheville à frapper","Cheville Molly","Cheville","Ecrous A2 6mm","Vis Agglo","Pince"]
st=0.00
dicimg = {}
def erreur():
showerror('Erreur', 'Cette référence est fausse !')
def valider():
f=saisi.get()
g=s.get()
i=0
while i<(len(tref)):
i=i+1
if int(f) == tref[i]:
tnb[i]=int(g)
obj.append(int(f))
st=tprix[i]*tnb[i]
soust.append(st)
t.append(st)
nobj.append(tproduit[i])
soust1 = " Sous Total : %.2f " % st
texteLabel1=Label(fen1, text = soust1 )
texteLabel1.pack()
champ_label = Label(fen1, text=tproduit[i])
champ_label.pack(padx=5, pady=5)
image=timg[i]
image = Image.open(image)
photo = ImageTk.PhotoImage(image)
dicimg['img1'] = photo
canvas.create_image(420, 300, image=photo)
else:
erreur()
def prixtotal():
fen2=Tk()
l = LabelFrame(fen2, text="Panier", padx=20, pady=20)
l.pack(fill="both", expand="yes")
pt=sum(t)
Label(l,text="Commande").pack()
Label(l, text= nobj ).pack()
Label(l, text= obj).pack()
Label(l, text= soust).pack()
Label(l,text=" Prix Total : %.2f " % pt).pack()
Label(l, text=" Prix Total : %.2f " % pt,side=RIGHT).pack()
fen1=Tk()
fen1.configure(width=700,height=700)
fen1.title('Easy Commande')
canvas = Canvas(fen1,width=900, height=700, bg='white')
canvas.pack(side=LEFT, padx=5, pady=5)
texteLabel1=Label(fen1, text = "Entrez la référence :")
texteLabel1.pack()
saisi=Entry(fen1)
saisi.pack(padx =3, pady =5)
s = Spinbox(fen1, from_=1, to=99999999999)
s.pack()
bouton1=Button(fen1, text="Valider", command=valider)
bouton1.pack()
bouton2=Button(fen1, text="Annuler", command=fen1.destroy)
bouton2.pack()
bouton3=Button(fen1, text="Panier", command=prixtotal)
bouton3.pack(side=RIGHT)
fen1.mainloop() |
Partager