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
|
from tkinter import *
from PIL import Image, ImageTk
from tkinter.messagebox import *
tref=[0,36671014,87076785,80614169]
tprix=[0,0.20,0.25,0.10]
tnb=[0,0,0,0]
timg=["chevillefrap.jpg","molly.png","cheville.jpg"]
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)
st=tprix[i]*tnb[i]
pt = " Sous Total : %.2f " % st
texteLabel1=Label(fen1, text = pt )
texteLabel1.pack()
image=timg[i]
image = Image.open(image)
photo = ImageTk.PhotoImage(image)
dicimg['img1'] = photo
canvas.create_image(350, 300, image=photo)
if tref[i]!=(len(tref)):
erreur()
def ajoutpanier():
canvas.delete(ALL)
texteLabel1.destroy()
fen1=Tk()
fen1.configure(width=700,height=700)
fen1.title('Easy Commande')
canvas = Canvas(fen1,width=700, height=700, bg='white')
canvas.pack()
bouton3=Button(fen1, text="Ajouter au panier", command=ajoutpanier)
bouton3.pack(side =RIGHT, padx =3, 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()
fen2=Tk()
fen2.configure(width=900,height=700)
fen2.title('Panier Easy Commande')
canvas1 = Canvas(fen2,width=700, height=700, bg='white')
canvas1.pack()
fen1.mainloop()
fen2.mainloop() |
Partager