<div dir="ltr"><div>Hello list, I want to design a battery monitoring system via raspberrypi. The voltage of battery is real changing data, I try to write some code, but the voltage can not change when I change the value of voltage.</div>
<div> </div><div>here is part of my code:</div><div> </div><div>import sys</div><div>from PyQt4 import QtGui,QtCore</div><div>import time</div><div> </div><div>class Example(QtGui.QWidget):</div><div>     </div><div>        def __init__(self):</div>
<div>              super(Example,self).__init__()</div><div> </div><div>              self.initUI()</div><div> </div><div>         def initUI(self):</div><div>               voltage=12 #e.g. I get the value of voltage is 12v</div>
<div>               </div><div>               voltageEdit=QtGui.QLabel(str(voltage),self)</div><div>               voltageEdit.resize(voltageEdit.sizeHint())</div><div>               voltageEdit.move(160,100)</div><div> </div>
<div>               time.sleep(5) # I want the GUI shows another value of voltage 5 seconds later</div><div> </div><div>               voltage=22</div><div>               voltageEdit=QtGui.QLabel(str(voltage),self)<div>               voltageEdit.resize(voltageEdit.sizeHint())</div>
<div>               voltageEdit.move(160,100)</div><div> </div><div>               grid=QtGui.QGridLayout()</div><div>               self.setLayout(grid)</div><div> </div><div>               self.setGeometry(300,200,600,400)</div>
<div>               self.setWindowTitle("battery status")</div><div>               self.show()</div><div> </div><div>def main():</div><div>        </div></div><div>         app=QtGui.QApplication(sys.argv)</div>
<div>         ex=Example()</div><div>         sys.exit(app.exec())</div><div> </div><div>if __name__='__main__':</div><div>         main()</div><div> </div><div> </div><div>When I executed this code, GUI shows the voltage is 12, and it will not change, please tell me how to fix it.</div>
<div> </div><div>thanks in advance,</div><div> </div><div>Harry</div><div>               </div></div>