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
| # -*- coding: cp1252 -*-
# Prototype de l'interface de notre programme
from math import *
from Tkinter import *
import sys # le programme marche sans mais c'était noté dans un tuto? oO
def pol(ca,pka):
if myvar==1:
r3=0.5*pka-0.5*log10(ca)
elif myvar==2:
r3=7+0.5*pka+0.5*log10(ca)
elif myvar==4:
r3=-log10(ca)
elif myvar==5:
r3=14+log10(ca)
print(r3)
fen1 = Tk()
fen1.title("Calcul de pH")
myvar= IntVar() # on cree une variable pour la valeur liee a la case cochee
# création de widgets 'Radiobutton':
r1=Radiobutton(fen1,text="Acide faible",variable=myvar,value=1, indicatoron=0).grid(row=1, column=1, sticky=W)
r2=Radiobutton(fen1,text=" Base faible ",variable=myvar,value=2, indicatoron=0).grid(row=2, column=1, sticky=W)
r4=Radiobutton(fen1,text="Acide fort",variable=myvar,value=4, indicatoron=0).grid(row=1, column=2, sticky=W)
r5=Radiobutton(fen1,text="Base forte",variable=myvar, value=5, indicatoron=0).grid(row=2, column=2, sticky=W)
# création de widget 'entry' et 'label':
lfirst=Label(fen1, text="Quel est le type de l'éspèce considérée?").grid(row=0, column=1)
l0=Label(fen1, text="Concentration de l'éspèce en question (en mol/l) :").grid(row=0, column=3, padx=20)
e0=Entry(fen1).grid(row=1, column=3, sticky=N)
l1=Label(fen1, text="pka?").grid(row=2, column=3, sticky=N)
e1=Entry(fen1).grid(row=3, column=3, sticky=N)
# création d'un widget 'Canvas' contenant une image bitmap :
#can1 = Canvas(fen1, width =370, height =300, bg ='white')
#photo = PhotoImage(file ='phscale.gif')
#item = can1.create_image(185, 150, image =photo)
#can1.grid(row=5, columnspan=5, padx=10, pady=10)
#b1 = Button(fen1,text="Calcul du pH", command=fen1.pol(e).grid(row=3, column=3, pady=50)
b1 = Button(fen1,text="Calcul du pH", command=pol).grid(row=3, column=3, pady=50)
# démarrage :
fen1.mainloop() |
Partager