edubrm/software/modules/ModuleA.py
2011-05-01 21:46:20 +02:00

36 lines
925 B
Python

from PyQt4.QtGui import QWidget
from PyQt4.QtCore import pyqtSlot
from PyQt4.QtCore import SIGNAL
from PyQt4.QtCore import QObject
from PyQt4.QtCore import QTimer
from ModuleAUi import Ui_ModuleA
from device import Device
class ModuleAWidget(QWidget):
def __init__(self):
QWidget.__init__(self)
self.ui = Ui_ModuleA()
self.ui.setupUi(self)
self.timer = QTimer()
QObject.connect(self.timer, SIGNAL("timeout()"), self.read_inputs)
def read_inputs(self):
r = self.dev.read()
v = r[1]/1023.0 * 3.3
self.ui.labelV.setText('%0.3f V' % v)
self.ui.progressV.setValue(1000*v)
class ModuleA():
def __init__(self):
self.title = 'Sources of Electricity'
self.widget = ModuleAWidget()
def start(self):
self.widget.dev = Device()
self.widget.timer.start(50)
def stop(self):
self.widget.timer.stop()