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(par1, par2, par3):
ca = float(par1.get())
pka = float(par2.get())
equation_index = par3.get()
print ca, pka, equation_index
fen1 = Tk()
fen1.title("Calcul de pH")
myvar= IntVar(value=1) # 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)
r1.grid(row=1, column=1, sticky=W)
r2=Radiobutton(fen1,text=" Base faible ",variable=myvar,value=2, indicatoron=0)
r2.grid(row=2, column=1, sticky=W)
r4=Radiobutton(fen1,text="Acide fort",variable=myvar,value=4, indicatoron=0)
r4.grid(row=1, column=2, sticky=W)
r5=Radiobutton(fen1,text="Base forte",variable=myvar, value=5, indicatoron=0)
r5.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)
e0.grid(row=1, column=3, sticky=N)
l1=Label(fen1, text="pka?").grid(row=2, column=3, sticky=N)
e1=Entry(fen1)
e1.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=lambda par1=e0, par2=e1, par3=myvar:pol(par1,par2, par3)).grid(row=3, column=3, pady=50)
# démarrage :
fen1.mainloop() |
Partager