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 133 134 135
|
from tkinter import*
class Pesee():
"différentes pesée"
poids=Pesee()
poids.total=0
poids.partiel=0
poids.tare=0
class Etat():
"etat des vis"
vis1=Etat()
vis1.marche=0
vis1.nom="maïs"
vis2=Etat()
vis2.marche=0
vis2.nom="soja"
vis3=Etat()
vis3.marche=0
vis3.nom="Minéral"
def switchvis(self):
"changement d'état de la vis self"
fen1.destroy
if self.marche==0:
self.marche=1
mess="on"
else:
self.marche=0
mess="off"
if self==vis1 :
indice1.configure(text=mess)
elif self==vis2:
indice2.configure(text=mess)
else:
indice3.configure(text=mess)
def tare():
poids.tare=poids.total
actualiserpoids(poids.total)
def actualiserpoids(x):
""
poids.total=int(x)
poids.partiel=poids.total-poids.tare
total.configure(text=str(poids.total)+' Kg')
partiel.configure(text=str(poids.partiel)+' Kg')
def choixration():
def stopfenetre():
vis1.ration=E1
vis2.ration=E2
vis3.ration=E3
fen2.destroy()
"entrer les quantités à mettre"
fen2=Tk()
global E1, E2, E3
E1=Entry(fen2)
E1.grid(row=1,column=2)
E2=Entry(fen2)
E2.grid(row=2,column=2)
E3=Entry(fen2)
E3.grid(row=3,column=2)
Label(fen2,text=vis1.nom).grid(row=1,column=1)
Label(fen2,text=vis2.nom).grid(row=2,column=1)
Label(fen2,text=vis3.nom).grid(row=3,column=1)
Button(fen2, text="Valider", command=stopfenetre).grid(row=4, column=2)
fen2.mainloop()
fen1=Tk()
indice1=Label(fen1,text='off')
indice1.grid(row =1, column =4)
indice2=Label(fen1,text='off')
indice2.grid(row =2, column =4)
indice3=Label(fen1,text='off')
indice3.grid(row =3, column =4)
total=Label(fen1,text='0 Kg')
total.grid(row =1, column =1)
partiel=Label(fen1,text='0 kg')
partiel.grid(row =1, column =2)
Scale(fen1, command=actualiserpoids).grid (row=4, column=1)
Button(fen1, text=vis1.nom , command=lambda:switchvis(vis1)).grid(row=1, column=5)
Button(fen1, text=vis2.nom , command=lambda:switchvis(vis2)).grid(row=2, column=5)
Button(fen1, text=vis3.nom , command=lambda:switchvis(vis3)).grid(row=3, column=5)
Button(fen1, text='tare', command=lambda:tare()).grid(row=2,column=2)
Button(fen1, text='choisir ration', command=lambda:choixration()).grid(row=5,column=5)
Button(fen1, text="quitter", command=fen1.destroy).grid(row=6, column=5)
fen1.mainloop() |
Partager