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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
from PyQt4 import QtCore, QtGui, uic
import time,sys
import threading
from PyQt4.QtGui import QApplication, QDialog, QListWidgetItem, QListWidget, QIcon
from PyQt4.Qt import *
(loadUserInterface, QWidget) = uic.loadUiType('pyemission.ui')
class emission_calibration(QThread):
def __init__(self, parent=None):
# super(emission_calibration, self).__init__(parent=parent)
QThread.__init__(self, parent)
self.exiting=False
def render(self):
self.run()
def measure(self):
global window
image ="notick.png"
self.emit(SIGNAL("output(QLabel, QString)"), window.ui.tick1, image )
window.ui.status.setText("Please wait for measure....")
def run(self):
applied_level = self.measure()
return
def __del__(self):
self.exiting = True
self.wait()
class Main(QWidget):
"""constructor"""
def __init__(self, parent = None):
global directory,dir_state,gene,defaultbase,IMP_path,base_selected
global base,gene,window
QWidget.__init__(self, parent)
self.ui = loadUserInterface()
self.ui.setupUi(self)
self.threadPool=[]
self.thread = emission_calibration()
# Connect the Buttons
self.connect(self.thread, SIGNAL("finished()"), self.updateUi)
self.connect(self.thread, SIGNAL("terminated()"), self.updateUi)
QtCore.QObject.connect(self.ui.calibration,QtCore.SIGNAL("clicked()"),self.calibration)
self.connect(self.thread, SIGNAL("output(QLabel, QString)"), self.addImage)
dir_state = ''
directory = ''
def addImage(self, label, image):
pixmap = QPixmap(label.size())
pixmap.load(image)
label.setPixmap(pixmap)
def calibration(self):
self.ui.calibration.setEnabled(False)
self.thread.render()
def updateUi(self):
self.ui.calibration.setEnabled(True)
def main():
global window,debug
app = QtGui.QApplication(sys.argv)
window = Main()
window.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main() |
Partager