5
file becherlistwidget.py: part of the package pyacidobasic version %s:
7
Copyright (C) 2010 Georges Khaznadar <georgesk@ofset.org>
9
This program is free software: you can redistribute it and/or modify
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation, either version 3 of the License, or
12
(at your option) any later version.
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
19
You should have received a copy of the GNU General Public License
20
along with this program. If not, see <http://www.gnu.org/licenses/>.
23
from PyQt4.QtCore import *
24
from PyQt4.QtGui import *
25
from prelevement import concentrationVolumePrelevement
27
class BecherListWidget(QListWidget):
28
def __init__(self,parent):
29
QListWidget.__init__(self,parent)
32
def renseigneParametres(self,ab):
34
Renseigne les paramètres manquants pour l'acide/base ajouté
36
ab.c, ab.v=concentrationVolumePrelevement(ab.nom)
40
Supprime les contenus de la liste
42
for r in range(self.count()):
47
def findMainWindow(self):
49
trouve la fenêtre principale
51
for t in QApplication.topLevelWidgets():
52
if len(t.windowTitle())>0:
56
def dropEvent(self, event):
57
QListWidget.dropEvent(self, event)
58
for r in range (self.count()):
59
nom=self.item(r).text()
60
for ab in self.listeAcidesBases:
62
if ab.nom.toUtf8()==nom.toUtf8():
67
self.renseigneParametres(newAb)
68
self.contenu.append(newAb)
71
self.insertItem(r,self.nouveauTexte(newAb))
72
# on envoie un signal pour dire qu'il faut tracer les courbes
73
QApplication.postEvent(self.findMainWindow(), QEvent(QEvent.User))
75
def nouveauTexte(self,ab):
77
Le nouveau texte à afficher concernent l'acide/base
78
@param ab : l'acide/base à considérer
80
return "%s %s mol/L, %s mL" %(ab.nom,ab.c,ab.v)
82
def chargeNette(self,pH):
84
Renvoie la charge électrique des produits mis dans le bécher
85
en fonction du pH, compte non tenu des ions H+ et de ce qui vient
86
de la burette. UNité du résultat : Faraday
90
for ab in self.contenu:
91
charge+=ab.chargeNette(pH)
94
def chargeEau(self,pH):
96
renvoie la charge électrique porté par les protons et les ions
97
hydroxyde, en fonction du pH
101
for ab in self.contenu:
103
return (10**(-pH)-10**(pH-14))*v*1e-3
105
def charge(self, pH):
107
Renvoie la charge électrique totale, en fonction du pH
110
return self.chargeNette(pH) + self.chargeEau(pH)