Пример #1
0
class Test(QtGui.QMainWindow):
	def __init__(self):
		super(Test, self).__init__()
		self.ui = Ui_Form()
		self.ui.setupUi(self)
		self.ui.Upload.clicked.connect(self.openFile)
		self.ui.Generate.clicked.connect(self.Run)
		self.ui.Clear.clicked.connect(self.Clear)
		self.setStyleSheet("QMainWindow {background-color: #A4A4A4; color: #000000}")
		#self.setStyleSheet("QLineEdit { background-color: yellow}");
		self.show()

	def openFile(self):
		f = QtGui.QFileDialog.getOpenFileName(self, 'Open File', '.')
		f = open(f, 'r')
		self.ui.Input.setText(f.read())
		f.close()

	def Run(self):
		self.inputList = self.ui.Input.toPlainText().split('\n')
		register, ok = QtGui.QInputDialog.getText(self, 'Input',
                'Enter number of Registers')
		if not ok:
            		register = "2"
			QtGui.QMessageBox.question(self, 'Message', 'You pressed Cancel. Default r = 2 will be taken', QtGui.QMessageBox.Ok)
		elif register == "":
			register = "2"
			QtGui.QMessageBox.question(self, 'Message', 'You did not enter anything. Default r = 2 will be taken', QtGui.QMessageBox.Ok)
		register = int(register)
		main.Main(Writer(self.ui.Output), self.inputList, register)

	def Clear(self):
		self.ui.Output.setText('')
Пример #2
0
def main():
    #Create application
    app = QtWidgets.QApplication(sys.argv)

    #Create Form and UI
    Form = QtWidgets.QWidget()
    ui = Ui_Form()
    ui.setupUi(Form)
    Form.show()

    #Hook logic
    def input():
        try:
            ui.label_7.setText("")
            l1 = int(ui.lineEdit.text())
            l2 = int(ui.lineEdit_2.text())
            e = int(ui.lineEdit_3.text())
            text = int(ui.textEdit.toPlainText())
            C, n, k = ecrypto(l1, l2, e, text)
            ui.textEdit_3.setText(str(C))
            ui.lineEdit_4.setText(str(n))
            ui.lineEdit_5.setText(str(k))
        except:
            ui.label_7.setText("Дані введено не коректно")

    ui.pushButton_3.clicked.connect(input)

    #Run main loop
    sys.exit(app.exec_())
Пример #3
0
def main():
    #Create application
    app = QtWidgets.QApplication(sys.argv)

    #Create Form and UI
    Form = QtWidgets.QWidget()
    ui = Ui_Form()
    ui.setupUi(Form)
    Form.show()

    #Hook logic
    def bp():
        start_time = time.time()
        try:
            ui.label_7.setText("")
            x = ui.lineEdit.text()
            n = Factor(int(x))
            ui.textEdit.setText(str(n))
            ui.label_6.setText(str(time.time() - start_time))
        except:
            ui.label_7.setText("Дані введено не коректно")

    ui.pushButton.clicked.connect(bp)

    #Run main loop
    sys.exit(app.exec_())
Пример #4
0
def main():
    #Create application
    app = QtWidgets.QApplication(sys.argv)

    #Create Form and UI
    Form = QtWidgets.QWidget()
    ui = Ui_Form()
    ui.setupUi(Form)
    Form.show()

    #Hook logic
    def input():
        try:
            ui.label_6.setText("")
            z = int(ui.lineEdit.text())
            e = int(ui.lineEdit_2.text())
            l1, l2, l3 = output(z, e)
            ui.textEdit.setText(l1)
            ui.textEdit_2.setText(l2)
            ui.textEdit_3.setText(l3)
        except:
            ui.label_6.setText("Дані введено не коректно")

    ui.pushButton.clicked.connect(input)

    #Run main loop
    sys.exit(app.exec_())
Пример #5
0
def main():
    #Create application
    app = QtWidgets.QApplication(sys.argv)

    #Create Form and UI
    Form = QtWidgets.QWidget()
    ui = Ui_Form()
    ui.setupUi(Form)
    Form.show()

    #Hook logic
    def y():
        try:
            ui.label_3.setText("")
            ui.label_14.setText("")
            ui.label_15.setText("")
            e = int(ui.lineEdit.text())
            n = int(ui.lineEdit_2.text())
            x = int(ui.lineEdit_4.text())
            C = int(ui.textEdit.toPlainText())
            y = (C * (x**e)) % n
            ui.lineEdit_3.setText(str(y))
        except:
            ui.label_3.setText("Дані введено не коректно")

    def fun2():
        try:
            ui.label_3.setText("")
            ui.label_14.setText("")
            ui.label_15.setText("")
            n = int(ui.lineEdit_2.text())
            d = int(ui.lineEdit_5.text())
            y = int(ui.lineEdit_3.text())
            z = (y**d) % n
            ui.textEdit_4.setText(str(z))
        except:
            ui.label_14.setText("Дані введено не коректно")

    def decrypt():
        try:
            ui.label_3.setText("")
            ui.label_14.setText("")
            ui.label_15.setText("")
            z = int(ui.textEdit_3.toPlainText())
            n = int(ui.lineEdit_2.text())
            y = int(ui.lineEdit_3.text())
            x = int(ui.lineEdit_4.text())
            gcd, xx, y = egcd(x, n)
            M = (z * xx) % n
            ui.textEdit_2.setText(str(M))
        except:
            ui.label_15.setText("Дані введено не коректно")

    ui.pushButton_2.clicked.connect(y)
    ui.pushButton_3.clicked.connect(fun2)
    ui.pushButton.clicked.connect(decrypt)

    #Run main loop
    sys.exit(app.exec_())
Пример #6
0
class MyForm(QtGui.QMainWindow):

	def __init__(self, parent=None):

		QtGui.QWidget.__init__(self, parent)
		self.ui = Ui_Form()
		self.ui.setupUi(self)
		QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.ui.textEdit.clear)
		QtCore.QObject.connect(self.ui.lineEdit, QtCore.SIGNAL("returnPressed()"), self.add_entry)

		def add_entry(self):

			self.ui.lineEdit.selectAll()
			self.ui.lineEdit.cut()
			self.ui.textEdit.append("")
			self.ui.textEdit.paste()
Пример #7
0
class MyForm(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        # Signals/Slots
        QtCore.QObject.connect(self.ui.addSlideButton, QtCore.SIGNAL("clicked()"), self.addSlide)
        QtCore.QObject.connect(self.ui.deleteSlideButton, QtCore.SIGNAL("clicked()"), self.deleteSlide)
        QtCore.QObject.connect(self.ui.saveButton, QtCore.SIGNAL("clicked()"), self.save)

    def _addFileToList(self, filename):
        if not filename.isEmpty():
            item = QListWidgetItem(os.path.basename(unicode(filename)))
            picture = QtGui.QImage()
            picture.load(filename)
            picture.scaled(72, 72)
            icon = QIcon(QPixmap.fromImage(picture))
            item.setStatusTip(filename)
            item.setIcon(icon)
            self.ui.listWidget.addItem(item)

    def addSlide(self):
        files = QtGui.QFileDialog.getOpenFileNames(
            self, "Add slide", os.path.expanduser("~"), "Image Files (*.png *.jpg *.bmp)"
        )
        for filename in files:
            self._addFileToList(filename)

    def deleteSlide(self):
        self.ui.listWidget.takeItem(self.ui.listWidget.currentRow())

    def save(self):
        filename = QtGui.QFileDialog.getSaveFileName(self, "Save background", "background.xml", "XML file (*.xml)")

        if not filename:
            return -1

        # Generate animated background
        listOfSlides = []
        for i in range(self.ui.listWidget.count()):
            listOfSlides.append(unicode(self.ui.listWidget.item(i).statusTip()))

        xml_handler = xmlgenerator.XmlGenerator(
            listOfSlides, self.ui.slideSpinBox.value(), self.ui.transitionSpinBox.value()
        )
        xml_handler.saveTo(unicode(filename))
Пример #8
0
class Main(QWidget):
    def __init__(self):
        super(Main, self).__init__()

        # Set up the user interface from Designer
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        # Connect signals
        self.ui.pushButton.clicked.connect(self.send)

        # Set params
        self.ui.textEdit.setReadOnly(True)
        self.ui.textEdit.setFontPointSize(16)

    def send(self):
        self.ui.textEdit.append(self.ui.lineEdit.text())
Пример #9
0
class Main(QWidget):
    def __init__(self):
        super(Main, self).__init__()

        # Set up the user interface from Designer
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        # Connect signals
        self.ui.pushButton.clicked.connect(self.btngo)
        self.ui.pushButton_2.clicked.connect(self.btngetfilepath)

        self.ui.pushButton.setEnabled(False)

        # Set params
        self.ui.textEdit_2.setReadOnly(True)
        self.ui.textEdit.setFontPointSize(16)
        self.ui.textEdit_2.setFontPointSize(16)
        self.ui.radioButton_2.setChecked(True)

        self.key_chars = []

    def btngo(self):
        if self.ui.radioButton_2.isChecked():
            mytext = self.ui.textEdit.toPlainText()
            txt = re.sub(r'[^A-Za-z]', '', mytext)
            self.ui.textEdit_2.setText(encrypt(txt.lower(), self.key_chars))

        if self.ui.radioButton.isChecked():
            mytext = self.ui.textEdit.toPlainText()
            txt = re.sub(r'[^A-Za-z]', '', mytext)
            self.ui.textEdit_2.setText(decrypt(txt.lower(), self.key_chars))

    def btngetfilepath(self):
        filename = QFileDialog.getOpenFileName(self, 'Open File', '',
                                               'Text Files (*.txt)')[0]
        try:
            f = open(filename, "r")
            with f:
                key = f.read().lower()
                key_nums = [k for k in key if k.isdigit()]
                self.key_chars = [k for k in key if not k.isdigit()]
                self.ui.pushButton.setEnabled(True)
        except FileNotFoundError:
            pass
Пример #10
0
class MyForm(QtGui.QMainWindow):
    def __init__(self, parent=None):

        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"),
                               self.ui.textEdit.clear)
        QtCore.QObject.connect(self.ui.lineEdit,
                               QtCore.SIGNAL("returnPressed()"),
                               self.add_entry)

        def add_entry(self):

            self.ui.lineEdit.selectAll()
            self.ui.lineEdit.cut()
            self.ui.textEdit.append("")
            self.ui.textEdit.paste()
Пример #11
0
class Test(QtGui.QMainWindow):
    def __init__(self):
        super(Test, self).__init__()
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.ui.Upload.clicked.connect(self.openFile)
        self.ui.Generate.clicked.connect(self.Run)
        self.ui.Clear.clicked.connect(self.Clear)
        self.setStyleSheet(
            "QMainWindow {background-color: #A4A4A4; color: #000000}")
        #self.setStyleSheet("QLineEdit { background-color: yellow}");
        self.show()

    def openFile(self):
        f = QtGui.QFileDialog.getOpenFileName(self, 'Open File', '.')
        f = open(f, 'r')
        self.ui.Input.setText(f.read())
        f.close()

    def Run(self):
        self.inputList = self.ui.Input.toPlainText().split('\n')
        register, ok = QtGui.QInputDialog.getText(self, 'Input',
                                                  'Enter number of Registers')
        if not ok:
            register = "2"
            QtGui.QMessageBox.question(
                self, 'Message',
                'You pressed Cancel. Default r = 2 will be taken',
                QtGui.QMessageBox.Ok)
        elif register == "":
            register = "2"
            QtGui.QMessageBox.question(
                self, 'Message',
                'You did not enter anything. Default r = 2 will be taken',
                QtGui.QMessageBox.Ok)
        register = int(register)
        main.Main(Writer(self.ui.Output), self.inputList, register)

    def Clear(self):
        self.ui.Output.setText('')
Пример #12
0
from PySide2.QtWidgets import *
from gui import Ui_Form
import requests
import sys

url = 'http://api.openweathermap.org/data/2.5/weather'
api = open('sysFiles/config.txt', 'r').readline()

if __name__ == '__main__':
    app = QApplication(sys.argv)

    Form = QWidget()
    ui = Ui_Form()
    ui.setupUi(Form)
    Form.show()


def search():

    if ui.lineEdit.text() == '':
        ui.label_2.setText("Введите название города (Поселка)")
    else:

        try:
            params = {
                'APPID': api,
                'q': ui.lineEdit.text(),
                'units': 'metric',
                'lang': 'ru'
            }
            result = requests.get(url, params=params)
Пример #13
0
class MyWidget(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)

        self.lastSelectedIDir = ''
        self.lastSelectedODir = ''
        self.lastSelectedMDir = ''

        self.ui = Ui_Form()
        self.ui.setupUi(self)

        self.loadPreferences()

        self.thread = Worker()
        #self.connect(self.thread, QtCore.SIGNAL('updateProgressBar'), self.updateProgressBar)
        #self.connect(self.thread, QtCore.SIGNAL('runFinished'), self.runFinished)

        self.ui.inputDirButton.clicked.connect(self.selectInputDir)
        self.ui.outputDirButton.clicked.connect(self.selectOutputDir)
        self.ui.moveDirButton.clicked.connect(self.selectMoveDir)
        self.ui.runButton.clicked.connect(self.performChecks)
        self.ui.moveDirCheckBox.clicked.connect(self.savePreferences)
        self.ui.showKnownCheckBox.clicked.connect(self.savePreferences)
        self.ui.fastFoldCheckBox.clicked.connect(self.savePreferences)
        self.ui.stbmsCheckBox.clicked.connect(self.savePreferences)
        self.ui.saveErrorsCheckBox.clicked.connect(self.savePreferences)

    def parsePreferencesFile(self):
        prefs = {}
        prefsFile = open('./hhcp51386797995611001157.hhcprefs', 'r')
        for line in prefsFile:
            sIdx = line.find('=')
            prefs[line[:sIdx]] = line.strip()[(sIdx + 1):]
        prefsFile.close()

        if 'inputPath' in prefs and prefs['inputPath']:
            self.ui.inputDirText.setText(prefs['inputPath'])
            self.lastSelectedIDir = prefs['inputPath']

        if 'outputPath' in prefs and prefs['outputPath']:
            self.ui.outputDirText.setText(prefs['outputPath'])
            self.lastSelectedODir = prefs['outputPath']

        if 'movePath' in prefs and prefs['movePath']:
            self.ui.moveDirText.setText(prefs['movePath'])
            self.lastSelectedMDir = prefs['movePath']

        if 'moveEnabled' in prefs and prefs['moveEnabled'] == 'False':
            self.ui.moveDirCheckBox.setChecked(False)

        if 'showKnown' in prefs and prefs['showKnown'] == 'True':
            self.ui.showKnownCheckBox.setChecked(True)

        if 'fastFold' in prefs and prefs['fastFold'] == 'True':
            self.ui.fastFoldCheckBox.setChecked(True)

        if 'separateTablesByMaxSeats' in prefs and prefs[
                'separateTablesByMaxSeats'] == 'True':
            self.ui.stbmsCheckBox.setChecked(True)

        if 'saveErrors' in prefs and prefs['saveErrors'] == 'True':
            self.ui.saveErrorsCheckBox.setChecked(True)

    def createNewPreferencesFile(self):
        prefsFile = open('./hhcp51386797995611001157.hhcprefs', 'w')
        prefsFile.write('inputPath=\n' + 'outputPath=\n' + 'movePath=\n' +
                        'moveEnabled=True\n' + 'showKnown=False\n' +
                        'fastFold=False\n' +
                        'separateTablesByMaxSeats=False\n' +
                        'saveErrors=False\n')
        prefsFile.close()

    def savePreferences(self):
        prefsFile = open('./hhcp51386797995611001157.hhcprefs', 'w')
        prefsFile.write('inputPath=' + self.lastSelectedIDir + '\n' +
                        'outputPath=' + self.lastSelectedODir + '\n' +
                        'movePath=' + self.lastSelectedMDir + '\n')

        if self.ui.moveDirCheckBox.isChecked():
            prefsFile.write('moveEnabled=True\n')
        else:
            prefsFile.write('moveEnabled=False\n')

        if self.ui.showKnownCheckBox.isChecked():
            prefsFile.write('showKnown=True\n')
        else:
            prefsFile.write('showKnown=False\n')

        if self.ui.fastFoldCheckBox.isChecked():
            prefsFile.write('fastFold=True\n')
        else:
            prefsFile.write('fastFold=False\n')

        if self.ui.stbmsCheckBox.isChecked():
            prefsFile.write('separateTablesByMaxSeats=True\n')
        else:
            prefsFile.write('separateTablesByMaxSeats=False\n')

        if self.ui.saveErrorsCheckBox.isChecked():
            prefsFile.write('saveErrors=True\n')
        else:
            prefsFile.write('saveErrors=False\n')

        prefsFile.close()

    def updateProgressBar(self, processedFiles, totalFiles):
        self.ui.progressBar.setValue(
            (float(processedFiles) / totalFiles) * 100)

    def runFinished(self, processedHandsTotal, numFilesWithHands):
        self.ui.statusLabel.setStyleSheet('color: black')
        self.ui.statusLabel.setText(
            str(processedHandsTotal) + ' hands processed in ' +
            str(numFilesWithHands) + ' file(s)')

        self.ui.runButton.setEnabled(True)
        self.ui.moveDirCheckBox.setEnabled(True)
        self.ui.showKnownCheckBox.setEnabled(True)
        self.ui.fastFoldCheckBox.setEnabled(True)
        self.ui.stbmsCheckBox.setEnabled(True)
        self.ui.saveErrorsCheckBox.setEnabled(True)

    def deactivateButtons(self):
        self.ui.runButton.setEnabled(False)
        self.ui.moveDirCheckBox.setEnabled(False)
        self.ui.showKnownCheckBox.setEnabled(False)
        self.ui.fastFoldCheckBox.setEnabled(False)
        self.ui.stbmsCheckBox.setEnabled(False)
        self.ui.saveErrorsCheckBox.setEnabled(False)

    def checkValidDirs(self, inputText, outputText, moveText, moveFiles):
        invalidDirs = []
        msg = ''

        inputDirValid = True
        outputDirValid = True
        moveDirValid = True

        #try:
        #    os.mkdir(inputText)
        #    os.mkdir(outputText)
        #    os.mkdir(moveText)
        #except WindowsError as e:
        #    pass

        if not os.path.exists(inputText):
            inputDirValid = False
            invalidDirs.append('input')
        else:
            self.lastSelectedIDir = inputText

        if not os.path.exists(outputText):
            outputDirValid = False
            invalidDirs.append('ouput')
        else:
            self.lastSelectedODir = outputText

        if os.path.exists(moveText):
            self.lastSelectedMDir = moveText

        self.savePreferences()

        if moveFiles:
            if not os.path.exists(moveText):
                moveDirValid = False
                invalidDirs.append('move')

            if inputDirValid and outputDirValid and moveDirValid:
                return True
            else:
                for i in invalidDirs:
                    msg += (i + '/')
                msg = msg[:-1]
                self.ui.statusLabel.setStyleSheet('color: red')
                self.ui.statusLabel.setText(msg + ' directory is not valid')
                return False
        else:
            if inputDirValid and outputDirValid:
                return True
            else:
                for i in invalidDirs:
                    msg += (i + '/')
                msg = msg[:-1]
                self.ui.statusLabel.setStyleSheet('color: red')
                self.ui.statusLabel.setText(msg + ' directory is not valid')
                return False

    def performChecks(self):
        inputText = str(self.ui.inputDirText.text()).strip()
        outputText = str(self.ui.outputDirText.text()).strip()
        moveText = str(self.ui.moveDirText.text()).strip()

        showKnown = False
        fastFold = False
        separateTablesByMaxSeats = False
        saveErrors = False

        if self.ui.showKnownCheckBox.isChecked():
            showKnown = True

        if self.ui.fastFoldCheckBox.isChecked():
            fastFold = True

        if self.ui.stbmsCheckBox.isChecked():
            separateTablesByMaxSeats = True

        if self.ui.saveErrorsCheckBox.isChecked():
            saveErrors = True

        if self.ui.moveDirCheckBox.isChecked():
            if not inputText or not outputText or not moveText:
                self.ui.statusLabel.setStyleSheet('color: red')
                self.ui.statusLabel.setText(
                    'input/output/move directory not specified')
            else:
                if inputText == outputText or inputText == moveText or outputText == moveText:
                    self.ui.statusLabel.setStyleSheet('color: red')
                    self.ui.statusLabel.setText(
                        'input/output/move directories cannot be the same')
                else:
                    if self.checkValidDirs(inputText, outputText, moveText,
                                           True):
                        self.deactivateButtons()
                        self.ui.statusLabel.setStyleSheet('color: black')
                        self.ui.statusLabel.setText('Running...')
                        self.thread.runConverter(inputText, outputText,
                                                 moveText, True, showKnown,
                                                 fastFold,
                                                 separateTablesByMaxSeats,
                                                 saveErrors)
        else:
            if not inputText or not outputText:
                self.ui.statusLabel.setStyleSheet('color: red')
                self.ui.statusLabel.setText(
                    'input/output directory not specified')
            else:
                if inputText == outputText:
                    self.ui.statusLabel.setStyleSheet('color: red')
                    self.ui.statusLabel.setText(
                        'input/output directories cannot be the same')
                else:
                    if self.checkValidDirs(inputText, outputText, moveText,
                                           False):
                        self.deactivateButtons()
                        self.ui.statusLabel.setStyleSheet('color: black')
                        self.ui.statusLabel.setText('Running...')
                        self.thread.runConverter(inputText, outputText,
                                                 moveText, False, showKnown,
                                                 fastFold,
                                                 separateTablesByMaxSeats,
                                                 saveErrors)

    def selectInputDir(self):
        iDir = QtGui.QFileDialog.getExistingDirectory(None, '',
                                                      self.lastSelectedIDir)
        if iDir:
            self.ui.inputDirText.setText(iDir)
            self.lastSelectedIDir = iDir

    def selectOutputDir(self):
        oDir = QtGui.QFileDialog.getExistingDirectory(None, '',
                                                      self.lastSelectedODir)
        if oDir:
            self.ui.outputDirText.setText(oDir)
            self.lastSelectedODir = oDir

    def selectMoveDir(self):
        mDir = QtGui.QFileDialog.getExistingDirectory(None, '',
                                                      self.lastSelectedMDir)
        if mDir:
            self.ui.moveDirText.setText(mDir)
            self.lastSelectedMDir = mDir

    def loadPreferences(self):
        if not os.path.exists('./hhcp51386797995611001157.hhcprefs'):
            self.createNewPreferencesFile()
        else:
            self.parsePreferencesFile()
Пример #14
0
class appWindow(QtGui.QWidget):
    
    def __init__(self):
        super().__init__()
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.ui.btn_openFile.clicked.connect(self.getFile)
        self.ui.btn_chart.clicked.connect(self.drawChart)
        self.ui.btn_allLeads.toggled.connect(self.toggleCheckboxes)
        
        
    def getFile(self):
        self.filename = QtGui.QFileDialog().getOpenFileName(self, 'Open File', '.', 'ECG files (*.ecg)')
        if self.filename != None:
            self.ecg = ECG(self.filename[0], 'cp1250')
            self.setWindowTitle('ECG test of {0} {1} taken {2:%Y-%b-%d %H:%M:%S}'.format(self.ecg.patientFirstName, self.ecg.patientLastName, self.ecg.datetimeStartOfTest))
            if self.ecg.numberOfLeads <= 10:
                j = 0
                positions = [(i,j) for i in range(0,self.ecg.numberOfLeads)]
            else:
                positions = [(i,j) for i in range(0,10) for j in range (0,2)]
            if len(positions) > self.ecg.numberOfLeads:
                for k in range(0,len(positions)-self.ecg.numberOfLeads):
                    positions.pop()
            axis = CAxisTime(orientation='bottom')
            self.plot = pg.PlotItem(axisItems={'bottom': axis}, enableMenu=False)
            self.curves = []
            self.leads = {}
            for idx, (position, lead) in enumerate(zip(positions, self.ecg.leadsNames)):
                self.leads[lead] = idx
                self.checkbox = QtWidgets.QCheckBox(lead, self.ui.gb_channels)
                self.checkbox.setObjectName(lead)
                self.ui.gb_channels_layout.addWidget(self.checkbox, position[0], position[1])
            checkbox = self.ui.gb_channels.findChild(QtWidgets.QCheckBox, self.ecg.leadsNames[0])
            checkbox.toggle()
            
            btn_chbox = self.findChild(QtWidgets.QPushButton, 'btn_allLeads')
            btn_chbox.setEnabled(True)
            
    def drawChart(self):
        if self.windowTitle() == 'Form':
            self.getFile()
        leads = []
        leadsNames = []
        nr = 0
        for chbox in self.ui.gb_channels.findChildren(QtWidgets.QCheckBox):
            if chbox.isChecked():
                color = pg.intColor(nr, self.ecg.numberOfLeads*1.3)
                chbox.setStyleSheet('color: {0}'.format(color.name()))
                leads.append(self.leads[chbox.objectName()])
                leadsNames.append(chbox.objectName())
                nr += 1
        if len(leads) < 1:
            checkbox = self.ui.gb_channels.findChild(QtWidgets.QCheckBox, self.ecg.leadsNames[0])
            checkbox.toggle()
            for chbox in self.ui.gb_channels.findChildren(QtWidgets.QCheckBox):
                if chbox.isChecked():
                    color = pg.intColor(nr, self.ecg.numberOfLeads*1.3)
                    chbox.setStyleSheet('color: {0}'.format(color.name()))
                    leads.append(self.leads[chbox.objectName()])
                    leadsNames.append(chbox.objectName())
                    nr += 1
        #Freq = str(int((1/self.ecg.samplingRate)*10**9)) + 'N'
        indexes = np.arange(self.ecg.datetimeStartOfTest.timestamp(), self.ecg.datetimeEndOfTest.timestamp(),1/self.ecg.samplingRate)
        if len(indexes) > len(self.ecg.ecgInChannels[0]):
            indexes = indexes[0:len(self.ecg.ecgInChannels[0])]
        step = 30*self.ecg.samplingRate
        numberOfSamples = 10**5 #setting over 10**7 will take a lot of time to plot
        if numberOfSamples > len(self.ecg.ecgInChannels[0]):
            numberOfSamples = len(self.ecg.ecgInChannels[0])
        winsize = len(leads)*numberOfSamples / step * 100
        self.ui.graphicsView.setMinimumSize(QtCore.QSize(1000,winsize))
        self.ui.graphicsView.clear()
        for idx, i in enumerate(range(0, numberOfSamples, step)):
             axis1 = DateAxis(orientation='bottom')
             axis = CAxisTime(orientation='bottom')
             self.plot = self.ui.graphicsView.addPlot(row=idx, col=0, axisItems={'bottom': axis}, enableMenu=False)
             for n, lead in enumerate(leads):
                 ecg = self.ecg.ecgInChannels[lead].reshape(-1)
                 c = pg.PlotDataItem(pen=(n, self.ecg.numberOfLeads*1.3), downsample=10, downsampleMethod='subsample', name=leadsNames[n])
                 c.setData(x=indexes[i:i+step-1:4], y=ecg[i:i+step-1:4])
                 self.plot.addItem(c)
                 c.setPos(0,3*n*self.ecg.leadsResolution[0])
                 self.plot.setYRange(-2*self.ecg.leadsResolution[0], 3*self.ecg.leadsResolution[0]*len(leads))
                 self.plot.setXRange(indexes[i], indexes[i+step-1])
             self.plot.disableAutoRange()
             self.plot.setMouseEnabled(x=False, y=False)
             
    def toggleCheckboxes(self):
        btn = self.findChild(QtWidgets.QPushButton, 'btn_allLeads')
        if btn.isChecked():
            btn.setText('Uncheck All Leads')
            for chbox in self.ui.gb_channels.findChildren(QtWidgets.QCheckBox):
                if not chbox.isChecked():
                    chbox.toggle()
        else:
            btn.setText('Check All Leads')
            for chbox in self.ui.gb_channels.findChildren(QtWidgets.QCheckBox):
                if chbox.isChecked():
                    chbox.toggle()
Пример #15
0
class MyForm(QtGui.QMainWindow,QtCore.QThread):
    tick = QtCore.pyqtSignal(int, name="changed") #New style signal
    def __init__(self, parent=None):
        QtCore.QThread.__init__(self)
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.filebrower) #for input file
        QtCore.QObject.connect(self.ui.pushButton_2, QtCore.SIGNAL("clicked()"), self.submit) #submit
        QtCore.QObject.connect(self.ui.pushButton_3, QtCore.SIGNAL("clicked()"), self.reset) #reset
        QtCore.QObject.connect(self.ui.pushButton_4, QtCore.SIGNAL("clicked()"), self.add_taxid1) #add taxid to include
        QtCore.QObject.connect(self.ui.pushButton_5, QtCore.SIGNAL("clicked()"), self.add_taxid2) #add taxid to exclude
        QtCore.QObject.connect(self.ui.pushButton_6, QtCore.SIGNAL("clicked()"), self.advance) #add taxid to exclude
        self.ui.progressBar.hide()
        self.ui.progressBar.setProperty("value", 0)
        self.ui.lineEdit_add3 = QtGui.QLineEdit(self.ui.groupBox_2)
        self.ui.lineEdit_add3.setGeometry(QtCore.QRect(70, 20, 281, 21))
        self.ui.lineEdit_add3.setObjectName("lineEdit_3")
        self.ui.lineEdit_add3.setText(QtGui.QApplication.translate("Form", "", None, QtGui.QApplication.UnicodeUTF8))
        completer = QCompleter()
        self.ui.lineEdit_add3.setCompleter(completer)
        model = QStringListModel()
        completer.setModel(model)
        completer.setModelSorting(QCompleter.CaseInsensitivelySortedModel)
        Expar.get_data(model)
        self.ui.lineEdit_add2 = QtGui.QLineEdit(self.ui.groupBox_4)
        self.ui.lineEdit_add2.setGeometry(QtCore.QRect(70, 19, 281, 21))
        self.ui.lineEdit_add2.setObjectName("lineEdit_2")
        self.ui.lineEdit_add2.setText(QtGui.QApplication.translate("Form", "", None, QtGui.QApplication.UnicodeUTF8))
        completer = QCompleter()
        self.ui.lineEdit_add2.setCompleter(completer)
        model = QStringListModel()
        completer.setModel(model)
        completer.setModelSorting(QCompleter.CaseInsensitivelySortedModel)
        Expar.get_data(model)
        self.dbdir=os.path.join(os.path.expanduser("~"),".pyqtodo")
        self.dbfile=os.path.join(self.dbdir,str(int(time.time()))+"tasks.sqlite")
        if not os.path.isdir(self.dbdir):
            os.mkdir(self.dbdir)
            # Set up the Elixir internal thingamajigs
        elixir.metadata.bind = "sqlite:///%s"%self.dbfile
        elixir.setup_all()
        if not os.path.exists(self.dbfile):
            elixir.create_all()
        global saveData
        if elixir.__version__ < "0.6":
            saveData=elixir.session.flush
        else:
            saveData=elixir.session.commit
        saveData()
    def filebrower(self):
        fname = QtGui.QFileDialog.getOpenFileName(self, 'Open file', './')
        self.ui.lineEdit.setText(fname)
    def add_taxid1(self):
            mid=" OR "
            if  self.ui.lineEdit_5.text()=="":
                self.ui.lineEdit_5.setText(self.ui.lineEdit_add3.text())
            else:
                self.ui.lineEdit_5.setText(self.ui.lineEdit_add3.text()+mid+self.ui.lineEdit_5.text())
            self.ui.lineEdit_add3.setText("")
    def add_taxid2(self):
            mid=" OR "
            if  self.ui.lineEdit_15.text()=="":
                self.ui.lineEdit_15.setText(self.ui.lineEdit_add2.text())
            else:
                self.ui.lineEdit_15.setText(self.ui.lineEdit_add2.text()+mid+self.ui.lineEdit_15.text())
            self.ui.lineEdit_add2.setText("")
    def submit(self):
        input_filename=Expar.input_content(self.ui.textEdit.toPlainText(),self.ui.lineEdit.text())
        if input_filename!='':
            Expar.main_page(input_filename,self.ui.lineEdit_5.text(),self.ui.lineEdit_15.text(),self.ui.checkBox.isChecked(),self.ui.checkBox_2.isChecked(),self.ui.checkBox_3.isChecked(),int(self.ui.lineEdit_10.text()),int(self.ui.lineEdit_9.text()),int(self.ui.lineEdit_2.text()),int(self.ui.lineEdit_3.text()))
            #Expar.main_page('HSV2.fasta','hsv2 (taxid:10310) OR hsv-1 (taxid:10298)','h**o (taxid:9605)',self.ui.checkBox.isChecked(),self.ui.checkBox_2.isChecked(),self.ui.checkBox_3.isChecked(),int(self.ui.lineEdit_10.text()),int(self.ui.lineEdit_9.text()),int(self.ui.lineEdit_2.text()),int(self.ui.lineEdit_3.text()))
            self.dialog = QtGui.QDialog()
            self.dialog.ui = Ui_Dialog()
            self.dialog.ui.setupUi(self.dialog)
            QtCore.QObject.connect(self.dialog.ui.pushButton, QtCore.SIGNAL("clicked()"), self.submit2) #submit
            QtCore.QObject.connect(self.dialog.ui.pushButton_3, QtCore.SIGNAL("clicked()"), self.savefilefinger)
            for finger in todo.Task.query.all():
                item=QtGui.QTreeWidgetItem([str(finger.finger_id),str(finger.finger_type),str(finger.start),str(finger.length),str(finger.sequence),str(finger.exclude),str(finger.include)])
                #print "exclude:",str(finger.exclude)
                item.finger=finger
                item.setCheckState(0,QtCore.Qt.Checked)
                self.dialog.ui.list.sortByColumn(0, QtCore.Qt.AscendingOrder)
                self.dialog.ui.list.addTopLevelItem(item)
                self.dialog.ui.list.setSortingEnabled(True)
                self.dialog.ui.list.setColumnWidth(4,250)
            self.dialog.exec_()
    def submit2(self):
        self.ui.progressBar.hide()
        iterator = QtGui.QTreeWidgetItemIterator(self.dialog.ui.list)
        task_list={}
        while True:
            value = iterator.value()
            if value is None:
                break
            if value.checkState(0):
                task_list[str(value.text(0))]=1
            else:
                print ""
            iterator.__iadd__(1)
        if task_list==[]:
            return
        #print task_list
        self.dialog2 = QtGui.QDialog()
        self.dialog2.ui = Ui_Dialog2()
        self.dialog2.ui.setupUi(self.dialog2)
        QtCore.QObject.connect(self.dialog2.ui.pushButton, QtCore.SIGNAL("clicked()"), self.savefilebrower_all)
        for finger in todo.Task.query.all():
            if task_list.has_key(str(finger.finger_id)):
                if str(finger.finger_type)=='HTH':
                    QtGui.QMessageBox.warning(Form,"Warning", "HTH fingerprinting sites may take a long time to process!")
                    break
        for finger in todo.Task.query.all():
            self.tick.emit(1)
            SeqDep.delete_file('~tem')
            SeqDep.delete_file('~tri')
            if task_list.has_key(str(finger.finger_id)):
                name='seq_'+str(finger.finger_id)+'_'+str(finger.finger_type)+'_'+str(finger.start)+'_'+str(finger.length)
                finger.done=True
                elixir.session.commit
                Expar_database.templet_generation_and_prediction(finger.sequence, name, int(self.ui.lineEdit_9.text()),int(self.ui.lineEdit_10.text()), float(self.ui.lineEdit_11.text()), float(self.ui.lineEdit_12.text()),float(self.ui.lineEdit_13.text()),float(self.ui.lineEdit_7.text()))
                #Expar_database.templet_generation_and_prediction(finger.sequence, name,8, 30, 37, 0,1,0.00000005)
        for tritemp in todo.Tritemp.query.all():
            item=QtGui.QTreeWidgetItem([str(tritemp.finger_id),str(tritemp.type),str(tritemp.start),str(tritemp.trig_gen),str(tritemp.trigger),str(tritemp.temp), str(tritemp.temp_bayes_class),str(tritemp.temp_pwm_class), str(tritemp.temp_p90_score),str(tritemp.temp_diff_score),str(tritemp.tri_temp_tm),str(tritemp.temp_tm),str(tritemp.bonds)])
            self.dialog2.ui.list.sortByColumn(0, QtCore.Qt.AscendingOrder)
            self.dialog2.ui.list.addTopLevelItem(item)
            self.dialog2.ui.list.setSortingEnabled(True)
            self.dialog2.ui.list.setColumnWidth(4,250)
        #print SeqDep.method_2_prediction(finger.sequence)
        print "************************************\nDone!\n**************************************\n"
        self.dialog2.exec_()

    def reset(self):
                self.ui.lineEdit_9.setText('8')# minimum trigger length
                self.ui.lineEdit_10.setText('30') # maximum trigger length
                self.ui.checkBox.setChecked(True) #checkbox for H-H
                self.ui.checkBox_2.setChecked(True) #checkbox for H-T
                self.ui.checkBox_3.setChecked(True) #checkbox for T-H
                self.ui.lineEdit_11.setText('37') # temperature
                self.ui.lineEdit_12.setText('1') # Na+
                self.ui.lineEdit_13.setText('0') # Mg2+
                self.ui.radioButton.setChecked(True) #um selected for two step hybridization
                self.ui.radioButton_5.setChecked(True) #um selected for strand concentration
                self.ui.lineEdit_7.setText('0.00005')#strand concentration
    def savefilebrower_all(self):
        print "entered savefilebrower_all"
        fName = QtGui.QFileDialog.getSaveFileName(self, "Save as xls file", "Save as new file", self.tr("Text Files (*.xls)"))
        #print "step5", globals()
        if fName.isEmpty() == False:
            Expar.write_xls(str(fName),self, todo.Task.query.all(), todo.Tritemp.query.all())
            #t=file1+'simple.xls'
            #rb = xlrd.open_workbook(t)
            #wb = copy(rb)
            #print(rb.sheet_by_index(0).cell(0,0).value)
            #wb.save(fName)
            print(fName)
            print('is generated!')
            QtGui.QMessageBox.about(self, "Saved", "%s is generated!" % (fName))
            #SeqDep.delete_file('~') # delete all the files under this folder and begins with '~'
            SeqDep.delete_file2()
            self.close()
            exit()
    def savefilefinger(self):
        print "entered savefilefinger"
        fName = QtGui.QFileDialog.getSaveFileName(self, "Save as xls file", "Save as new file", self.tr("Text Files (*.xls)"))
        if fName.isEmpty() == False:
            Expar.write_xls_2(str(fName),self, todo.Task.query.all(), todo.Tritemp.query.all())
            print(fName)
            print('is generated!')
            QtGui.QMessageBox.about(self, "Saved", "%s is generated!" % (fName))
    def advance(self):
        self.dialog_advance = QtGui.QDialog()
        self.dialog_advance.ui= advance.Ui_Dialog()
        self.dialog_advance.ui.setupUi(self.dialog_advance)
        self.dialog_advance.connect(self.dialog_advance.ui.buttonBox,QtCore.SIGNAL("accepted()"), self.saveAdvancedSettings)
        self.dialog_advance.exec_()
    def saveAdvancedSettings(self):
        configure_finger.min_tri_temp_tm=float(self.dialog_advance.ui.lineEdit.text())
        configure_finger.max_tri_temp_tm=float(self.dialog_advance.ui.lineEdit_2.text())
        configure_finger.max_temp_tm=float(self.dialog_advance.ui.lineEdit_4.text())
        configure_finger.max_temp_bonds=float(self.dialog_advance.ui.lineEdit_5.text())
Пример #16
0
class MyForm(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.ui.progressBar.hide()
        self.ui.pushButton_2.hide()
        self.ui.label_2.hide()
        QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.filebrower) #for input file
        QtCore.QObject.connect(self.ui.buttonBox, QtCore.SIGNAL(("accepted()")), self.submit) #submit
        QtCore.QObject.connect(self.ui.buttonBox, QtCore.SIGNAL(("rejected()")), self.reset) #submit
        QtCore.QObject.connect(self.ui.pushButton_6, QtCore.SIGNAL("clicked()"), self.advance) #advanced setting
        QtCore.QObject.connect(self.ui.pushButton_4, QtCore.SIGNAL("clicked()"), self.add_taxid1) #add taxid to include
        QtCore.QObject.connect(self.ui.pushButton_5, QtCore.SIGNAL("clicked()"), self.add_taxid2) #add taxid to exclude
        QtCore.QObject.connect(self.ui.pushButton_2, QtCore.SIGNAL("clicked()"), self.savefilebrower_all) #for input file
        self.ui.lineEdit_3 = QtGui.QLineEdit(self.ui.groupBox_2)
        self.ui.lineEdit_3.setGeometry(QtCore.QRect(70, 20, 270, 21))
        self.ui.lineEdit_3.setObjectName("lineEdit_3")
        self.ui.lineEdit_3.setText(QtGui.QApplication.translate("Form", "", None, QtGui.QApplication.UnicodeUTF8))
        completer = QCompleter()
        self.ui.lineEdit_3.setCompleter(completer)
        model = QStringListModel()
        completer.setModel(model)
        completer.setModelSorting(QCompleter.CaseInsensitivelySortedModel)
        Proxar_GUI3.get_data(model)
        self.ui.lineEdit_13 = QtGui.QLineEdit(self.ui.groupBox_4)
        self.ui.lineEdit_13.setGeometry(QtCore.QRect(70, 20, 270, 21))
        self.ui.lineEdit_13.setObjectName("lineEdit_13")
        self.ui.lineEdit_13.setText(QtGui.QApplication.translate("Form", "", None, QtGui.QApplication.UnicodeUTF8))
        completer = QCompleter()
        self.ui.lineEdit_13.setCompleter(completer)
        model = QStringListModel()
        completer.setModel(model)
        completer.setModelSorting(QCompleter.CaseInsensitivelySortedModel)
        Proxar_GUI3.get_data(model)
        #self.ui.lineEdit_5.setText('Mycobacterium avium (taxid:1764) OR Mycobacterium bovis (taxid:1765)')# include list
        #self.ui.lineEdit_15.setText('h**o sapiens (taxid:9606)')
        self.ui.lineEdit.setText('short_example206.txt')

    def filebrower(self):
        fname = QtGui.QFileDialog.getOpenFileName(self, 'Open file', './')
        self.ui.lineEdit.setText(fname)

    def add_taxid1(self):
        mid=" OR "
        if  self.ui.lineEdit_5.text()=="":
            self.ui.lineEdit_5.setText(self.ui.lineEdit_3.text())
        else:
            self.ui.lineEdit_5.setText(self.ui.lineEdit_5.text()+mid+self.ui.lineEdit_3.text())
        self.ui.lineEdit_3.setText("")

    def add_taxid2(self):
        mid=" OR "
        if  self.ui.lineEdit_15.text()=="":
            self.ui.lineEdit_15.setText(self.ui.lineEdit_13.text())
        else:
            self.ui.lineEdit_15.setText(self.ui.lineEdit_15.text()+mid+self.ui.lineEdit_13.text())
        self.ui.lineEdit_13.setText("")

    def savefilebrower_all(self):
        fName = QtGui.QFileDialog.getSaveFileName(self, "Save as xls file", "Save as new file", self.tr("Excel Files (*.xls)"))
        if fName.isEmpty() == False:
            self.write_xls(fName)
            QtGui.QMessageBox.about(self, "Saved", "%s is generated!" % (fName))
            Proxar_GUI3.delete_file(configure.tempname)
            self.close()

    def write_xls(self,filename):
        book = Workbook()
        sheet1 = book.add_sheet('Whole PT/PX Combinations',cell_overwrite_ok=True)
        sheet2 = book.add_sheet('Desired thermo',cell_overwrite_ok=True)
        sheet3 = book.add_sheet('All submitted templates',cell_overwrite_ok=True)

        row11 = sheet1.row(0)
        row11.write(0,'PT_name')
        row11.write(1,'PT_sequence')
        row11.write(2,'PX_name')
        row11.write(3,'PX_sequence')

        i=1
        for record in SeqIO.parse(seq_file, "fasta") :
            if i%2==1:
                row11 = sheet1.row(i)
                row11.write(0, str(record.id))
                row11.write(1, str(record.seq))
            else:
                row11.write(2, str(record.id))
                row11.write(3, str(record.seq))
                i=i+1



        row21 = sheet2.row(0)
        row21.write(0,'name')
        row21.write(1,'sequence')
        row21.write(2,'bayes_class')
        row21.write(3,'pwm_class')
        row21.write(4,'p90 score')
        row21.write(5,'diff score')
        row21.write(6,'tri-temp Tm')
        row21.write(7,'temp-temp Tm')
        row21.write(8,'bonds')


        row31 = sheet3.row(0)
        row31.write(0,'name')
        row31.write(1,'sequence')
        row31.write(2,'bayes_class')
        row31.write(3,'pwm_class')
        row31.write(4,'p90 score')
        row31.write(5,'diff score')
        row31.write(6,'tri-temp Tm')
        row31.write(7,'temp-temp Tm')
        row31.write(8,'bonds')

        book.save(filename)

    def newgui5(self):
        self.ui.progressBar.show()
        self.ui.progressBar.reset()
        self.ui.progressBar.setMinimum(0)
        self.ui.progressBar.setMaximum(10)
        while configure.progress_simbol>9:
            time.sleep(1)
            self.ui.progressBar.setValue(configure.progress_simbol)
            self.ui.progressBar.update()
            if configure.progress_simbol>9:
                break
        self.ui.pushButton_2.show()
        self.ui.progressBar.hide()

    def submit(self):
        #Proxar_GUI3.main_page(target_file=self.ui.lineEdit.text(),include_line=self.ui.lineEdit_5.text(), exclude_line=self.ui.lineEdit_15.text(), hairpin_file='hairpin.txt',extra_base_file='extra_base.txt', templates_file='good_template.txt',exclude_GAGTC=self.ui.checkBox.isChecked(),two_direction=self.ui.checkBox_2.isChecked(),PT_foot_min=self.ui.lineEdit_6.text(),PT_foot_max=self.ui.lineEdit_9.text(),PT_Tm_above=self.ui.lineEdit_10.text(),PX_foot_min=self.ui.lineEdit_8.text(),PX_foot_max=self.ui.lineEdit_11.text() ,PX_Tm_above=self.ui.lineEdit_12.text(),max_gap = self.ui.lineEdit_7.text(),pt_longer_num=self.ui.lineEdit_14.text(),px_longer_num=self.ui.lineEdit_16.text())
        whole_PT2='good_template.txt_wholePT.txttemp_pass_bind.txt'
        whole_PX1='px_foot_hair_file2.txttemp_pass_bind.txt'
        exclude_line='h**o sapiens (taxid:9606)'
        pt_longer_num=19
        px_longer_num=15
        #self.ui.progressBar.show()
        #self.ui.progressBar.reset()
        self.ui.buttonBox.hide()
        self.ui.pushButton_6.hide()
        print "ok"
        time.sleep(5)
        self.ui.pushButton_2.show()                                                                
        primer_design.main_page(self.ui.lineEdit.text(),self.ui.lineEdit_5.text(),self.ui.lineEdit_15.text(),\
                                                            'hairpin.txt','extra_base.txt','good_template.txt',self.ui.checkBox.isChecked(),\
                                                            self.ui.checkBox_2.isChecked(),\
                                                            self.ui.lineEdit_6.text(),self.ui.lineEdit_9.text(),configure.pt_foot_tm,\
                                                            self.ui.lineEdit_8.text(),\
                                                            self.ui.lineEdit_11.text(),configure.px_foot_tm,self.ui.lineEdit_7.text(),\
                                                            self.ui.lineEdit_14.text(),\
                                                            self.ui.lineEdit_16.text(),\
                                                            configure.pt_foot_conc,\
                                                            configure.px_foot_conc, configure.pt_px_foot_match_max,\
                                                            configure.hair_tar_max,\
                                                            configure.overhang_pt_tar_max,\
                                                            configure.overhang_px_tar_max)
       
          #main_page(target_file,include_line, exclude_list, 
          #hairpin_file,extra_base_file, templates_file,exclude_GAGTC,
          #two_direction,
          #PT_foot_min,PT_foot_max,PT_Tm_above,
          #PX_foot_min,
          #PX_foot_max,PX_Tm_above,max_gap,
          ##PT_discard_longer_tahn_default 19)
          #PX_discard_longer_tahn_default 19
          #...)
    def reset(self):
        self.ui.lineEdit.setText('J:\PROXAR\2-23-2012\short_example.txt') #file
        self.ui.lineEdit_6.setText('23')# PT foot min
        self.ui.lineEdit_9.setText('29') # PT foot max
        self.ui.lineEdit_10.setText('4') # PX mismatch
        self.ui.lineEdit_4.setText('4') # PT mismatch
        self.ui.lineEdit_8.setText('21') # PX foot min
        self.ui.lineEdit_11.setText('23') # PX foot max
        self.ui.lineEdit_12.setText('0') # PT above Tm
        self.ui.lineEdit_7.setText('2') # gap
        self.ui.lineEdit_5.setText('Mycobacterium avium (taxid:1764) OR Mycobacterium bovis (taxid:1765)')# include list
        self.ui.lineEdit_15.setText('')# exclude list
        self.ui.lineEdit_14.setText('19')
        self.ui.lineEdit_16.setText('15')
        self.checkBox.setChecked(True)
        self.checkBox_4.setChecked(True)
        self.checkBox_3.setChecked(True)
        self.checkBox_2.setChecked(True)

    def advance(self):
        self.dialog_advance = QtGui.QDialog()
        self.dialog_advance.ui = advance.Ui_Dialog()
        self.dialog_advance.ui.setupUi(self.dialog_advance)
        self.dialog_advance.connect(self.dialog_advance.ui.buttonBox, QtCore.SIGNAL("accepted()"), self.saveAdvancedSettings)
        self.dialog_advance.exec_()


    def saveAdvancedSettings(self):
        #configure.progress_simbol=
        configure.pt_foot_conc=float(self.dialog_advance.ui.lineEdit_2.text())
        configure.px_foot_conc=float(self.dialog_advance.ui.lineEdit_4.text())
        configure.pt_foot_tm=float(self.dialog_advance.ui.lineEdit.text())
        configure.px_foot_tm=float(self.dialog_advance.ui.lineEdit_3.text())
        configure.pt_px_foot_match_max=int(self.dialog_advance.ui.lineEdit_5.text())
        configure.hair_tar_max=int(self.dialog_advance.ui.lineEdit_6.text())
        configure.whole_PT_tm=float(self.dialog_advance.ui.lineEdit_8.text())
        configure.whole_PX_tm=float(self.dialog_advance.ui.lineEdit_9.text())
        configure.overhang_pt_tar_max=int(self.dialog_advance.ui.lineEdit_7.text())
        configure.overhang_px_tar_max=int(self.dialog_advance.ui.lineEdit_10.text())
Пример #17
0
class PyASM(QtGui.QMainWindow):
	"""
	Application class responsible for the instantiation of the GUI and simulation of the Software Machine.
	@extends QtGui.QMainWindow framework for building the application's GUI
	"""
	
	def __init__(self):
		"""
		Constructor. 
		Inititalizes GUI, event handling, hotkeys, etc
		"""
		super(PyASM, self).__init__()
		self.ui = Ui_Form(); self.ui.setupUi(self)
		self.ui.step.clicked.connect(self.run)
		self.ui.run.clicked.connect(self.runFull)
		self.initSIM()
		self.ui.memory.verticalHeader().setVisible(False)
		self.ui.memory.setRowCount(32768)
		self.newItem = QtGui.QTableWidgetItem
		self.setWindowTitle('Software Machine v1.3')
		
		openFile = QtGui.QAction('&Open', self)
		openFile.setShortcut('Ctrl+O')
		openFile.triggered.connect(self.loadProgramFromFile)
		refreshProgram = QtGui.QAction('&Refresh', self)
		refreshProgram.setShortcut('Ctrl+R')
		refreshProgram.triggered.connect(self.loadInstructions)
		aboutProgram = QtGui.QAction('&About', self)
		aboutProgram.triggered.connect(self.aboutProgram)
		exitAction = QtGui.QAction('&Exit', self)
		exitAction.setShortcut('Ctrl+Q')
		exitAction.triggered.connect(QtGui.qApp.quit)
		self.ui.r0.clicked.connect(self.showRegInfoR0)
		self.ui.r1.clicked.connect(self.showRegInfoR1)
		self.ui.r2.clicked.connect(self.showRegInfoR2)
		self.ui.r3.clicked.connect(self.showRegInfoR3)
		self.ui.r4.clicked.connect(self.showRegInfoR4)
		self.ui.r5.clicked.connect(self.showRegInfoR5)
		self.ui.r6.clicked.connect(self.showRegInfoR6)
		self.ui.r7.clicked.connect(self.showRegInfoR7)
		self.ui.pc.clicked.connect(self.showRegInfoPC)
		
		menubar = self.menuBar()
		fileMenu = menubar.addMenu('&Menu')
		fileMenu.addAction(openFile)
		fileMenu.addAction(refreshProgram)
		fileMenu.addAction(exitAction)
		helpMenu = menubar.addMenu('&Help')
		helpMenu.addAction(aboutProgram)
		
		stepButton = QtGui.QAction(self)
		stepButton.setShortcut('F11')
		stepButton.triggered.connect(self.run)
		self.ui.step.addAction(stepButton)
		runButton = QtGui.QAction(self)
		runButton.setShortcut('F5')
		runButton.triggered.connect(self.runFull)
		self.ui.run.addAction(runButton)
		
		self.running = "on"
		
		row = 0
		i = 0
		for row in range(0, 32768):
			self.ui.memory.setItem(row, 0, self.newItem(inttohex(i)))
			self.ui.memory.setItem(row, 1, self.newItem("0000"))
			self.ui.memory.item(row, 0).setFlags(QtCore.Qt.ItemIsSelectable)
			i += 2
		self.ui.flags.setText("Flags:\nZ     E     G     L  .\n")
		self.updateUI()
		self.show()

	def updateUI(self):
		"""
		Updates the the GUI with the backend data used by the simulator
		"""
		self.ui.r0.setText("R0:	       " + self.regbank["000"])
		self.ui.r1.setText("R1:	       " + self.regbank["001"])
		self.ui.r2.setText("R2:	       " + self.regbank["010"])
		self.ui.r3.setText("R3:	       " + self.regbank["011"])
		self.ui.r4.setText("R4:	       " + self.regbank["100"])
		self.ui.r5.setText("R5:	       " + self.regbank["101"])
		self.ui.r6.setText("R6:	       " + self.regbank["110"])
		self.ui.r7.setText("R7:	       " + self.regbank["111"])
		self.regbank["pc"] = inttohex(2 * self.pc)
		self.ui.pc.setText("PC:	       " + self.regbank["pc"])
		tmp = hextobin(self.regbank["flags"])
		self.ui.flagZ.setCheckState(int(tmp[-16]))
		self.ui.flagE.setCheckState(int(tmp[-15]))
		self.ui.flagG.setCheckState(int(tmp[-14]))
		self.ui.flagL.setCheckState(int(tmp[-13]))
		
	def initSIM(self):
		"""
		Initialize the backend of the Simulator. 
		"""
		self.instructionTable = {"000000":self.instruction_NEG,
								 "000001":self.instruction_AND,
								 "000010":self.instruction_XOR,
								 "000011":self.instruction_OR,
								 "000100":self.instruction_LSR,
								 "000101":self.instruction_LSL,
								 "000110":self.instruction_ASR,
								 "000111":self.instruction_TST,
								 "001000":self.instruction_ROR,
								 "001001":self.instruction_ROL,
								 "001010":self.instruction_HLT,
								 "001011":None,
								 "001100":self.instruction_MOVB,
								 "001101":self.instruction_MOV,
								 "001110":self.instruction_CMP,
								 "001111":self.instruction_JMP,
								 "010000":self.instruction_ADD,
								 "010001":self.instruction_SUB,
								 "010010":self.instruction_PUSH,
								 "010011":self.instruction_POP,
								 "010100":self.instruction_CALL,
								 "010101":self.instruction_RET
								 }
		self.regbank = {"000":"0000",
						"001":"0000",
						"010":"0000",
						"011":"0000",
						"100":"0000",
						"101":"0000",
						"110":"0000",
						"111":"0000",
						"flags":"0000",
						"pc":"0000",
						"sp":"FFFE"
						}
		self.pc = 0
		self.prevpc = 0
		self.initialPC = 0
		self.initialLoadAddress = 0
		
	def loadProgramFromFile(self):
		"""
		Load a program from a file. Opens a QFileDialog instance to read the input program file to the text editor in the Simulator.
		"""
		file = QtGui.QFileDialog.getOpenFileName(self, 'Open File', '.')
		file = open(file, 'r')
		self.ui.instructions.setText(file.read())
		file.close()
		self.loadInstructions()
		
	def loadInstructions(self):
		"""
		Instructions to be given to the simulator are read from the text editor and are loaded to memory.
		"""
		self.regbank["000"] = "0000"
		self.regbank["001"] = "0000"
		self.regbank["010"] = "0000"
		self.regbank["011"] = "0000"
		self.regbank["100"] = "0000"
		self.regbank["101"] = "0000"
		self.regbank["110"] = "0000"
		self.regbank["111"] = "0000"
		self.regbank["flags"] = "0000"
		self.regbank["pc"] = "0000"
		self.regbank["sp"] = "FFFE"
		addr, ok = QtGui.QInputDialog.getText(self, 'Input Dialog', 'Enter starting address to place instructions (default : 0000)')
		if not ok or addr == "":
			addr = "0000"
		addr = int(addr, 16)
		tmp, ok = QtGui.QInputDialog.getText(self, 'Input Dialog', 'Enter value of PC (default : 0000)')
		if not ok or tmp == "":
			tmp = "0000"
		self.pc = int(int(tmp, 16)/2)
		i = addr
		
		instructions = self.ui.instructions.toPlainText().split("\n")
		for inst in instructions:
			if inst != "":
				self.setWord(i, inst)
				i += 2
		self.updateUI()
		self.defaultColor = self.ui.memory.item(0, 0).background()
		self.running = "on"
		self.previnst = ""
	
	def run(self):
		"""
		Runs the next instruction (if any). Equivalent to 'step'
		"""
		if self.running == "on" and self.pc < 32768:
			if self.previnst != "":
				self.ui.memory.item(self.prevpc-1, 1).setBackground(self.defaultColor)
				if self.previnst[-2:] == "10" or self.previnst[-2:] == "11" or self.previnst[-7:-5] == "10" or self.previnst[-7:-5] == "11":
					self.ui.memory.item(self.prevpc-2, 1).setBackground(self.defaultColor)
			inst = hextobin(self.nextInstruction())
			self.simulateInstruction(inst)
			self.updateUI()
			self.previnst = inst
			
	def runFull(self):
		"""
		Runs the whole program (or the remaining) till the end of the program. Equivalent to 'run'
		"""
		while self.running == "on" and self.pc < 32768:
			self.run()
		
	def nextInstruction(self):
		"""
		Obtains the next word from memory which can be used either as instruction/data and highlights it.
		@return 4 digit hex string
		"""
		inst = self.ui.memory.item(self.pc, 1).text()
		self.ui.memory.item(self.pc, 1).setBackground(QtGui.QBrush(QtGui.QColor(0, 255, 255)))
		self.pc += 1
		self.prevpc = self.pc
		return inst
		# boundary conditions to be added
		
	def simulateInstruction(self, inst):
		"""
		Starts simulation of the instruction provided. 
		@param inst instruction to be simulated. 
		"""
		self.instructionTable[inst[-16:-10]](inst)
	
	def instruction_NEG(self, inst):
		"""
		Simulation of NEG (negation)
		Details in specs document
		@param inst NEG instruction 
		"""
		src1 = self.getOperandOneWord(inst)
		self.setDestinationWord(inst, ~src1)
	
	def instruction_AND(self, inst):
		"""
		Simulation of AND (bitwise and)
		Details in specs document
		@param inst AND instruction 
		"""
		src1 = self.getOperandOneWord(inst)
		src2 = self.getOperandTwoWord(inst)
		self.setDestinationWord(inst, src1 & src2)
	
	def instruction_XOR(self, inst):
		"""
		Simulation of XOR (bitwise xor)
		Details in specs document
		@param inst NEG instruction 
		"""
		src1 = self.getOperandOneWord(inst)
		src2 = self.getOperandTwoWord(inst)
		self.setDestinationWord(inst, src1 ^ src2)
	
	def instruction_OR(self, inst):
		"""
		Simulation of OR (or)
		Details in specs document
		@param inst OR instruction 
		"""
		src1 = self.getOperandOneWord(inst)
		src2 = self.getOperandTwoWord(inst)
		self.setDestinationWord(inst, src1 | src2)
	
	def instruction_LSR(self, inst):
		"""
		Simulation of LSR (Logical Right-Shift)
		Details in specs document
		@param inst LSR instruction 
		"""
		src1 = self.getOperandOneWord(inst)
		src2 = self.getOperandTwoWord(inst)
		self.setDestinationWord(inst, src2 >> src1)
	
	def instruction_LSL(self, inst):
		"""
		Simulation of LSL (Logical Left-Shift) - Also applies for ASL (Arithmetic Left-Shift)
		Details in specs document
		@param inst LSL instruction 
		"""
		src1 = self.getOperandOneWord(inst)
		src2 = self.getOperandTwoWord(inst)
		self.setDestinationWord(inst, src2 << src1)
	
	def instruction_ASR(self, inst):
		"""
		Simulation of ASR (Arithmetic Right-Shft)
		Details in specs document
		@param inst ASL instruction 
		"""
		src1 = self.getOperandOneWord(inst)
		src2 = self.getOperandTwoWord(inst)
		if src2 > 32767:
			src2 -= 65536
		self.setDestinationWord(inst, src2 >> src1)
	
	def instruction_TST(self, inst):
		"""
		Simulation of TST (Test bit)
		Details in specs document
		@param inst TST instruction 
		"""
		if inst[-7:-5] == "00":
			src = int(self.regbank[inst[-10:-7]], 16)
		elif inst[-7:-5] == "01":
			src = int(self.getWord(int(self.regbank[inst[-10:-5]], 16)), 16)
			
		bit = 2**(int(inst[-4:], 2))
		if bit & src == 0:
			tmp = "1000000000000000"
		else:
			tmp = "0000000000000000"
			
		self.regbank["flags"] = bintohex(tmp)
	
	def instruction_ROR(self, inst):
		"""
		Simulation of ROR (Rotate Right)
		Details in specs document
		@param inst ROR instruction 
		"""
		src1 = self.getOperandOneWord(inst)
		src2 = self.getOperandTwoWord(inst)
		self.setDestinationWord(inst, (src2 >> src1) | (src2 << (16-src1)))
		
	def instruction_ROL(self, inst):
		"""
		Simulation of ROL (Rotate Left)
		Details in specs document
		@param inst ROL instruction 
		"""
		src1 = self.getOperandOneWord(inst)
		src2 = self.getOperandTwoWord(inst)
		self.setDestinationWord(inst, (src2 << src1) | (src2 >> (16-src1)))
	
	def instruction_HLT(self, inst):
		"""
		Simulation of HLT (Halt)
		Details in specs document
		@param inst HLT instruction 
		"""
		self.running = "off"
	
	def instruction_MOVB(self, inst):
		"""
		Simulation of MOVB (Move byte)
		Details in specs document
		@param inst  instruction 
		"""
		src1 = self.getOperandOneByte(inst)
		self.setDestinationByte(inst, src1)
		
	def instruction_MOV(self, inst):
		"""
		Simulation of MOV (Move)
		Details in specs document
		@param inst MOV instruction 
		"""
		src1 = self.getOperandOneWord(inst)
		self.setDestinationWord(inst, src1)
		
	def instruction_CMP(self, inst):
		"""
		Simulation of CMP (Compare)
		Details in specs document
		@param inst CMP instruction 
		"""
		src2 = self.getOperandOneWord(inst)
		src1 = self.getOperandTwoWord(inst)
		self.updateFlags(src1, src2)
		
	def instruction_JMP(self, inst):
		"""
		Simulation of JMP (Jump/Branch). Different types of jumping use JMP with different flags set.
		Details in specs document
		@param inst  instruction 
		"""
		if inst[-2:] == "00":
			jmpdest = int(self.regbank[inst[-5:-2]], 16)
		elif inst[-2:] == "01":
			val = int(self.regbank[inst[-5:-2]], 16)
			if val > 32767:
				val -= 65536
			jmpdest = int(self.regbank["pc"], 16) + val
		elif inst[-2:] == "10":
			jmpdest = int(self.nextInstruction(), 16)
		elif inst[-2:] == "11":
			val = int(self.nextInstruction(), 16)
			if val > 32767:
				val -= 65536
			jmpdest = int(self.regbank["pc"], 16) + val
		if inst[-10] == "1":
			self.pc = int(jmpdest / 2)
		elif int(inst[-9:-5], 2) & int(hextobin(self.regbank["flags"])[-16:-12], 2) > 0:
			self.pc = int(jmpdest / 2)
		
	def instruction_ADD(self, inst):
		"""
		Simulation of ADD (addition)
		Details in specs document
		@param inst ADD instruction 
		"""
		src1 = self.getOperandOneWord(inst)
		src2 = self.getOperandTwoWord(inst)
		self.setDestinationWord(inst, src1 + src2)
		
	def instruction_SUB(self, inst):
		"""
		Simulation of SUB (subtraction)
		Details in specs document
		@param inst SUB instruction 
		"""
		src1 = self.getOperandOneWord(inst)
		src2 = self.getOperandTwoWord(inst)
		self.setDestinationWord(inst, src2 - src1)
		
	def instruction_PUSH(self, inst):
		"""
		Simulation of PUSH (push to stack)
		Details in specs document
		@param inst PUSH instruction 
		"""
		intsp = int(self.regbank["sp"], 16)
		self.setWord(intsp, inttohex(self.getOperandOneWord(inst)))
		self.regbank["sp"] = inttohex(intsp-2)
	
	def instruction_POP(self, inst):
		"""
		Simulation of POP (pop from stack)
		Details in specs document
		@param inst POP instruction 
		"""
		intsp = int(self.regbank["sp"], 16) + 2
		self.setDestinationWord(inst, int(self.getWord(intsp), 16))
		self.regbank["sp"] = inttohex(intsp)
		pass

	def instruction_CALL(self, inst):
		"""
		Simulation of CALL (sub-routine call)
		Details in specs document
		@param inst CALL instruction 
		"""
		if inst[-2:] == "00":
			jmpdest = int(self.regbank[inst[-5:-2]], 16)
		elif inst[-2:] == "01":
			val = int(self.regbank[inst[-5:-2]], 16)
			if val > 32767:
				val -= 65536
			jmpdest = int(self.regbank["pc"], 16) + val
		elif inst[-2:] == "10":
			jmpdest = int(self.nextInstruction(), 16)
		elif inst[-2:] == "11":
			val = int(self.nextInstruction(), 16)
			if val > 32767:
				val -= 65536
			jmpdest = int(self.regbank["pc"], 16) + val
		intsp = int(self.regbank["sp"], 16)
		self.setWord(intsp, inttohex(2*self.pc))
		self.regbank["sp"] = inttohex(intsp-2)
		self.pc = int(jmpdest / 2)

	def instruction_RET(self, inst):
		"""
		Simulation of RET (sub-routine return)
		Details in specs document
		@param inst RET instruction 
		"""
		intsp = int(self.regbank["sp"], 16) + 2
		self.pc = int(int(self.getWord(intsp), 16) / 2)
		self.regbank["sp"] = inttohex(intsp)

	def getOperandOneWord(self, inst):
		"""
		Gets a word denoted by bits 2 to 5 of the instruction
		@param inst instruction which contains flags set for the method of data access
		@return 4 digit hex string
		"""
		if inst[-2:] == "00":
			src1 = int(self.regbank[inst[-5:-2]], 16)
		elif inst[-2:] == "01":
			src1 = int(self.getWord(int(self.regbank[inst[-5:-2]], 16)), 16)
		elif inst[-2:] == "10":
			src1 = int(self.nextInstruction(), 16)
		return src1
	
	def getOperandOneByte(self, inst):
		"""
		Gets a byte denoted by bits 2 to 5 of the instruction
		@param inst instruction which contains flags set for the method of data access
		@return 2 digit hex string
		"""
		if inst[-2:] == "00":
			src1 = int(self.regbank[inst[-5:-2]][-2:], 16)
		elif inst[-2:] == "01":
			src1 = int(self.getByte(int(self.regbank[inst[-5:-2]], 16))[-2:], 16)
		elif inst[-2:] == "10":
			src1 = int((self.nextInstruction())[-2:], 16)
		return src1
	
	def getOperandTwoWord(self, inst):
		"""
		Gets a word denoted by bits 7 to 10 of the instruction
		@param inst instruction which contains flags set for the method of data access
		@return 4 digit hex string
		"""
		if inst[-7:-5] == "00":
			src2 = int(self.regbank[inst[-10:-7]], 16)
		elif inst[-7:-5] == "01":
			src2 = int(self.getWord(int(self.regbank[inst[-10:-7]], 16)), 16)
		return src2
	
	def getOperandTwoByte(self, inst):
		"""
		Gets a byte denoted by bits 7 to 10 of the instruction
		@param inst instruction which contains flags set for the method of data access
		@return 2 digit hex string
		"""
		if inst[-7:-5] == "00":
			src2 = int(self.regbank[inst[-10:-7]][-2:], 16)
		elif inst[-7:-5] == "01":
			src2 = int(self.getWord(int(self.regbank[inst[-10:-7]], 16))[-2:], 16)
		return src2
	
	def setDestinationWord(self, inst, dest):
		"""
		Sets a word denoted by bits 7 to 10 of the instruction
		@param inst instruction which contains flags set for the method of data access
		"""
		if inst[-7:-5] == "00":
			self.regbank[inst[-10:-7]] = inttohex(dest)
		elif inst[-7:-5] == "01":
			self.setWord(int(self.regbank[inst[-10:-7]], 16), inttohex(dest))
			
	def setDestinationByte(self, inst, dest):
		"""
		Sets a byte denoted by bits 7 to 10 of the instruction
		@param inst instruction which contains flags set for the method of data access
		"""
		if inst[-7:-5] == "00":
			self.regbank[inst[-10:-7]] = self.regbank[inst[-10:-17]][-4:-2] + inttohex(dest)[-2:] 
		elif inst[-7:-5] == "01":
			self.setByte(int(self.regbank[inst[-10:-7]], 16), inttohex(dest)[-2:])
	
	def getByte(self, byteNo):
		"""
		Gets a byte of data from memory
		@param byteNo the byte to be obtained
		@return 2 digit hex string
		"""
		if byteNo % 2 == 0:
			return self.ui.memory.item(byteNo, 1)[:2]
		else:
			return self.ui.memory.item(byteNo - 1, 1)[2:]
	
	def setByte(self, byteNo, val):
		"""
		Sets a byte of data in memory
		@param byteNo the byte to be set
		@param val value to be set in memory
		"""
		word = self.ui.memory.item(byteNo, 1)
		if byteNo % 2 == 0:
			word = val + word[2:] 
		else:
			word = word[:2] + val
		word = self.ui.memory.setItem(byteNo - (byteNo % 2), 1, self.newItem(word))
		
	def getWord(self, wordNo):
		"""
		Gets a word of data from memory
		@param wordNo the word to be obtained
		@return 4 digit hex string
		"""
		wordNo = int(wordNo / 2)
		return self.ui.memory.item(wordNo, 1).text()
	
	def setWord(self, wordNo, val):
		"""
		Sets a word of data in memory
		@param wordNo the word to be set
		@param val value to be set in memory
		"""
		wordNo = int(wordNo / 2)
		self.ui.memory.setItem(wordNo, 1, self.newItem(val))
		
	def updateFlags(self, src1, src2):
		"""
		Update flag register with respect to the values provided
		@param src1 1st value, operand one
		@param src2 2nd value, operand two
		"""
		flags = hextobin(self.regbank["flags"])
		if src1 == src2 != 0:
			flags = "0100" + flags[-12:]
		elif src1 == src2 == 0:
			flags = "1100" + flags[-12:]
		elif src1 < src2:
			flags = "0001" + flags[-12:]
		elif src1 > src2:
			flags = "0010" + flags[-12:]
		self.regbank["flags"] = bintohex(flags)
		
	def aboutProgram(self):
		"""
		Displays a message box about the Simulator
		"""
		QtGui.QMessageBox.information(self, 'About', 'Software Machine\nVersion 1.3\n\nDesigned and Developed by\nSathyam M Vellal', QtGui.QMessageBox.Ok)
		
	def showRegInfoR0(self):
		self.showRegInfo("000")
	def showRegInfoR1(self):
		self.showRegInfo("001")
	def showRegInfoR2(self):
		self.showRegInfo("010")
	def showRegInfoR3(self):
		self.showRegInfo("011")
	def showRegInfoR4(self):
		self.showRegInfo("100")
	def showRegInfoR5(self):
		self.showRegInfo("101")
	def showRegInfoR6(self):
		self.showRegInfo("110")
	def showRegInfoR7(self):
		self.showRegInfo("111")
	def showRegInfoPC(self):
		self.showRegInfo("pc")

	def showRegInfo(self, reg):
		"""
		Shows a dialog box with the info of the register
		"""
		info = ""
		info += "Integer : " + str(int(self.regbank[reg], 16)) + "\n"
		info += "Hexadecimal : " + self.regbank[reg] + "\n"
		bin = hextobin(self.regbank[reg])
		info += "Binary : " + bin[-16:-12] + " " + bin[-12:-8] + " " + bin[-8:-4] + " " + bin[-4:] + "\n"
		QtGui.QMessageBox.information(self, 'Register Information', info, QtGui.QMessageBox.Ok)
Пример #18
0
class MyForm(QtGui.QMainWindow, QtCore.QThread):
    tick = QtCore.pyqtSignal(int, name="changed")  #New style signal

    def __init__(self, parent=None):
        QtCore.QThread.__init__(self)
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"),
                               self.filebrower)  #for input file
        QtCore.QObject.connect(self.ui.pushButton_2,
                               QtCore.SIGNAL("clicked()"),
                               self.submit)  #submit
        QtCore.QObject.connect(self.ui.pushButton_3,
                               QtCore.SIGNAL("clicked()"), self.reset)  #reset
        QtCore.QObject.connect(self.ui.pushButton_4,
                               QtCore.SIGNAL("clicked()"),
                               self.add_taxid1)  #add taxid to include
        QtCore.QObject.connect(self.ui.pushButton_5,
                               QtCore.SIGNAL("clicked()"),
                               self.add_taxid2)  #add taxid to exclude
        QtCore.QObject.connect(self.ui.pushButton_6,
                               QtCore.SIGNAL("clicked()"),
                               self.advance)  #add taxid to exclude
        self.ui.progressBar.hide()
        self.ui.progressBar.setProperty("value", 0)
        self.ui.lineEdit_add3 = QtGui.QLineEdit(self.ui.groupBox_2)
        self.ui.lineEdit_add3.setGeometry(QtCore.QRect(70, 20, 281, 21))
        self.ui.lineEdit_add3.setObjectName("lineEdit_3")
        self.ui.lineEdit_add3.setText(
            QtGui.QApplication.translate("Form", "", None,
                                         QtGui.QApplication.UnicodeUTF8))
        completer = QCompleter()
        self.ui.lineEdit_add3.setCompleter(completer)
        model = QStringListModel()
        completer.setModel(model)
        completer.setModelSorting(QCompleter.CaseInsensitivelySortedModel)
        Expar.get_data(model)
        self.ui.lineEdit_add2 = QtGui.QLineEdit(self.ui.groupBox_4)
        self.ui.lineEdit_add2.setGeometry(QtCore.QRect(70, 19, 281, 21))
        self.ui.lineEdit_add2.setObjectName("lineEdit_2")
        self.ui.lineEdit_add2.setText(
            QtGui.QApplication.translate("Form", "", None,
                                         QtGui.QApplication.UnicodeUTF8))
        completer = QCompleter()
        self.ui.lineEdit_add2.setCompleter(completer)
        model = QStringListModel()
        completer.setModel(model)
        completer.setModelSorting(QCompleter.CaseInsensitivelySortedModel)
        Expar.get_data(model)
        self.dbdir = os.path.join(os.path.expanduser("~"), ".pyqtodo")
        self.dbfile = os.path.join(self.dbdir,
                                   str(int(time.time())) + "tasks.sqlite")
        if not os.path.isdir(self.dbdir):
            os.mkdir(self.dbdir)
            # Set up the Elixir internal thingamajigs
        elixir.metadata.bind = "sqlite:///%s" % self.dbfile
        elixir.setup_all()
        if not os.path.exists(self.dbfile):
            elixir.create_all()
        global saveData
        if elixir.__version__ < "0.6":
            saveData = elixir.session.flush
        else:
            saveData = elixir.session.commit
        saveData()

    def filebrower(self):
        fname = QtGui.QFileDialog.getOpenFileName(self, 'Open file', './')
        self.ui.lineEdit.setText(fname)

    def add_taxid1(self):
        mid = " OR "
        if self.ui.lineEdit_5.text() == "":
            self.ui.lineEdit_5.setText(self.ui.lineEdit_add3.text())
        else:
            self.ui.lineEdit_5.setText(self.ui.lineEdit_add3.text() + mid +
                                       self.ui.lineEdit_5.text())
        self.ui.lineEdit_add3.setText("")

    def add_taxid2(self):
        mid = " OR "
        if self.ui.lineEdit_15.text() == "":
            self.ui.lineEdit_15.setText(self.ui.lineEdit_add2.text())
        else:
            self.ui.lineEdit_15.setText(self.ui.lineEdit_add2.text() + mid +
                                        self.ui.lineEdit_15.text())
        self.ui.lineEdit_add2.setText("")

    def submit(self):
        input_filename = Expar.input_content(self.ui.textEdit.toPlainText(),
                                             self.ui.lineEdit.text())
        if input_filename != '':
            Expar.main_page(input_filename, self.ui.lineEdit_5.text(),
                            self.ui.lineEdit_15.text(),
                            self.ui.checkBox.isChecked(),
                            self.ui.checkBox_2.isChecked(),
                            self.ui.checkBox_3.isChecked(),
                            int(self.ui.lineEdit_10.text()),
                            int(self.ui.lineEdit_9.text()),
                            int(self.ui.lineEdit_2.text()),
                            int(self.ui.lineEdit_3.text()))
            #Expar.main_page('HSV2.fasta','hsv2 (taxid:10310) OR hsv-1 (taxid:10298)','h**o (taxid:9605)',self.ui.checkBox.isChecked(),self.ui.checkBox_2.isChecked(),self.ui.checkBox_3.isChecked(),int(self.ui.lineEdit_10.text()),int(self.ui.lineEdit_9.text()),int(self.ui.lineEdit_2.text()),int(self.ui.lineEdit_3.text()))
            self.dialog = QtGui.QDialog()
            self.dialog.ui = Ui_Dialog()
            self.dialog.ui.setupUi(self.dialog)
            QtCore.QObject.connect(self.dialog.ui.pushButton,
                                   QtCore.SIGNAL("clicked()"),
                                   self.submit2)  #submit
            QtCore.QObject.connect(self.dialog.ui.pushButton_3,
                                   QtCore.SIGNAL("clicked()"),
                                   self.savefilefinger)
            for finger in todo.Task.query.all():
                item = QtGui.QTreeWidgetItem([
                    str(finger.finger_id),
                    str(finger.finger_type),
                    str(finger.start),
                    str(finger.length),
                    str(finger.sequence),
                    str(finger.exclude),
                    str(finger.include)
                ])
                #print "exclude:",str(finger.exclude)
                item.finger = finger
                item.setCheckState(0, QtCore.Qt.Checked)
                self.dialog.ui.list.sortByColumn(0, QtCore.Qt.AscendingOrder)
                self.dialog.ui.list.addTopLevelItem(item)
                self.dialog.ui.list.setSortingEnabled(True)
                self.dialog.ui.list.setColumnWidth(4, 250)
            self.dialog.exec_()

    def submit2(self):
        self.ui.progressBar.hide()
        iterator = QtGui.QTreeWidgetItemIterator(self.dialog.ui.list)
        task_list = {}
        while True:
            value = iterator.value()
            if value is None:
                break
            if value.checkState(0):
                task_list[str(value.text(0))] = 1
            else:
                print ""
            iterator.__iadd__(1)
        if task_list == []:
            return
        #print task_list
        self.dialog2 = QtGui.QDialog()
        self.dialog2.ui = Ui_Dialog2()
        self.dialog2.ui.setupUi(self.dialog2)
        QtCore.QObject.connect(self.dialog2.ui.pushButton,
                               QtCore.SIGNAL("clicked()"),
                               self.savefilebrower_all)
        for finger in todo.Task.query.all():
            if task_list.has_key(str(finger.finger_id)):
                if str(finger.finger_type) == 'HTH':
                    QtGui.QMessageBox.warning(
                        Form, "Warning",
                        "HTH fingerprinting sites may take a long time to process!"
                    )
                    break
        for finger in todo.Task.query.all():
            self.tick.emit(1)
            SeqDep.delete_file('~tem')
            SeqDep.delete_file('~tri')
            if task_list.has_key(str(finger.finger_id)):
                name = 'seq_' + str(finger.finger_id) + '_' + str(
                    finger.finger_type) + '_' + str(finger.start) + '_' + str(
                        finger.length)
                finger.done = True
                elixir.session.commit
                Expar_database.templet_generation_and_prediction(
                    finger.sequence, name, int(self.ui.lineEdit_9.text()),
                    int(self.ui.lineEdit_10.text()),
                    float(self.ui.lineEdit_11.text()),
                    float(self.ui.lineEdit_12.text()),
                    float(self.ui.lineEdit_13.text()),
                    float(self.ui.lineEdit_7.text()))
                #Expar_database.templet_generation_and_prediction(finger.sequence, name,8, 30, 37, 0,1,0.00000005)
        for tritemp in todo.Tritemp.query.all():
            item = QtGui.QTreeWidgetItem([
                str(tritemp.finger_id),
                str(tritemp.type),
                str(tritemp.start),
                str(tritemp.trig_gen),
                str(tritemp.trigger),
                str(tritemp.temp),
                str(tritemp.temp_bayes_class),
                str(tritemp.temp_pwm_class),
                str(tritemp.temp_p90_score),
                str(tritemp.temp_diff_score),
                str(tritemp.tri_temp_tm),
                str(tritemp.temp_tm),
                str(tritemp.bonds)
            ])
            self.dialog2.ui.list.sortByColumn(0, QtCore.Qt.AscendingOrder)
            self.dialog2.ui.list.addTopLevelItem(item)
            self.dialog2.ui.list.setSortingEnabled(True)
            self.dialog2.ui.list.setColumnWidth(4, 250)
        #print SeqDep.method_2_prediction(finger.sequence)
        print "************************************\nDone!\n**************************************\n"
        self.dialog2.exec_()

    def reset(self):
        self.ui.lineEdit_9.setText('8')  # minimum trigger length
        self.ui.lineEdit_10.setText('30')  # maximum trigger length
        self.ui.checkBox.setChecked(True)  #checkbox for H-H
        self.ui.checkBox_2.setChecked(True)  #checkbox for H-T
        self.ui.checkBox_3.setChecked(True)  #checkbox for T-H
        self.ui.lineEdit_11.setText('37')  # temperature
        self.ui.lineEdit_12.setText('1')  # Na+
        self.ui.lineEdit_13.setText('0')  # Mg2+
        self.ui.radioButton.setChecked(
            True)  #um selected for two step hybridization
        self.ui.radioButton_5.setChecked(
            True)  #um selected for strand concentration
        self.ui.lineEdit_7.setText('0.00005')  #strand concentration

    def savefilebrower_all(self):
        print "entered savefilebrower_all"
        fName = QtGui.QFileDialog.getSaveFileName(
            self, "Save as xls file", "Save as new file",
            self.tr("Text Files (*.xls)"))
        #print "step5", globals()
        if fName.isEmpty() == False:
            Expar.write_xls(str(fName), self, todo.Task.query.all(),
                            todo.Tritemp.query.all())
            #t=file1+'simple.xls'
            #rb = xlrd.open_workbook(t)
            #wb = copy(rb)
            #print(rb.sheet_by_index(0).cell(0,0).value)
            #wb.save(fName)
            print(fName)
            print('is generated!')
            QtGui.QMessageBox.about(self, "Saved",
                                    "%s is generated!" % (fName))
            #SeqDep.delete_file('~') # delete all the files under this folder and begins with '~'
            SeqDep.delete_file2()
            self.close()
            exit()

    def savefilefinger(self):
        print "entered savefilefinger"
        fName = QtGui.QFileDialog.getSaveFileName(
            self, "Save as xls file", "Save as new file",
            self.tr("Text Files (*.xls)"))
        if fName.isEmpty() == False:
            Expar.write_xls_2(str(fName), self, todo.Task.query.all(),
                              todo.Tritemp.query.all())
            print(fName)
            print('is generated!')
            QtGui.QMessageBox.about(self, "Saved",
                                    "%s is generated!" % (fName))

    def advance(self):
        self.dialog_advance = QtGui.QDialog()
        self.dialog_advance.ui = advance.Ui_Dialog()
        self.dialog_advance.ui.setupUi(self.dialog_advance)
        self.dialog_advance.connect(self.dialog_advance.ui.buttonBox,
                                    QtCore.SIGNAL("accepted()"),
                                    self.saveAdvancedSettings)
        self.dialog_advance.exec_()

    def saveAdvancedSettings(self):
        configure_finger.min_tri_temp_tm = float(
            self.dialog_advance.ui.lineEdit.text())
        configure_finger.max_tri_temp_tm = float(
            self.dialog_advance.ui.lineEdit_2.text())
        configure_finger.max_temp_tm = float(
            self.dialog_advance.ui.lineEdit_4.text())
        configure_finger.max_temp_bonds = float(
            self.dialog_advance.ui.lineEdit_5.text())
Пример #19
0
class MyForm(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        QtCore.QObject.connect(self.ui.pushButton_stream_webcam, QtCore.SIGNAL("clicked()"), self.cmd_stream_webcam)
        QtCore.QObject.connect(self.ui.horizontalSlider_fps, QtCore.SIGNAL("valueChanged(int)"), self.cmd_fps_changed)
        QtCore.QObject.connect(self.ui.verticalSlider_red, QtCore.SIGNAL("valueChanged(int)"), self.cmd_red_slider_changed)
        QtCore.QObject.connect(self.ui.verticalSlider_green, QtCore.SIGNAL("valueChanged(int)"), self.cmd_green_slider_changed)
        QtCore.QObject.connect(self.ui.verticalSlider_blue, QtCore.SIGNAL("valueChanged(int)"), self.cmd_blue_slider_changed)
        QtCore.QObject.connect(self.ui.verticalSlider_gamma, QtCore.SIGNAL("valueChanged(int)"), self.cmd_gamma_slider_changed)
        QtCore.QObject.connect(self.ui.verticalSlider_brightness, QtCore.SIGNAL("valueChanged(int)"), self.cmd_brightness_slider_changed)


        # Network init
        self.sock = QtNetwork.QUdpSocket()
        self.sock.bind(QtNetwork.QHostAddress.Any, PORT)
        self.connect(self.sock, QtCore.SIGNAL("readyRead()"), self.on_recv_udp_packet)

        self.image = None
        self.streaming = False
        self.threshold = 128
        self.equalize = False
        self.fps = FRAMES_PER_SECOND
        self.time_between_frames = TIME_BETWEEN_FRAMES
        self.cam = cv.CaptureFromCAM(KAMERA_NR)

        self.max_red   = 100
        self.max_green = 100
        self.max_blue  = 100
        self.max_gamma = 100
        self.max_brightness = 100


    def cv_load_image(self, file_path):
        image = cv.LoadImage(file_path)
        conv_img = self.cv_get_converted_image_for_matelight(image)
        return conv_img

    def convert_img_matrix_to_matelight(self, mat):
        bitstring = []

        for row in xrange(mat.rows):
            for column in xrange(mat.cols):
                red   = int(mat[row, column][2] * self.max_red   / 100.0)
                green = int(mat[row, column][1] * self.max_green / 100.0)
                blue  = int(mat[row, column][0] * self.max_blue  / 100.0)
                bitstring.extend(struct.pack('BBB', red, green, blue))

        return bytearray(bitstring)

    def cv_resize_and_grayscale(self, input_image, threshold, doEqualize):
        image = cv.CreateImage((input_image.width, input_image.height), 8, 1)
        cv.CvtColor(input_image, image, cv.CV_BGR2GRAY)
    
        if doEqualize:
            cv.EqualizeHist(image, image) # equalize the pixel brightness
        cv.Threshold(image, image, threshold, 255, cv.CV_THRESH_OTSU) # convert to black / white image

        image_resized = cv.CreateImage( (RESX, RESY), image.depth, image.channels) # resize to fit into r0ket display
        cv.Resize(image, image_resized, cv.CV_INTER_NN)

        return image_resized


    # GUI events
    def cmd_load_image(self):
        file_path = str(self.ui.lineEdit_file_path.text())
        self.image = self.cv_load_image(file_path)
        print "image loaded!"

    def cmd_stream_webcam(self):
        end_time = 0
        counter = 1
        
        while True:
            frame = cv.QueryFrame(self.cam)
            c = cv.WaitKey(1)
        
            if c == 27: # esc
                return

            g = cv.CreateImage(cv.GetSize (frame), cv.IPL_DEPTH_8U, frame.channels)
            gr = frame[128: 384, 0: 640] # Crop from x, y, w, h -> 100, 200, 100, 200
            ml = cv.CreateImage((40, 16), cv.IPL_DEPTH_8U, frame.channels)
            cv.Resize(gr, ml)
            cv.ShowImage("Matelight TV", gr)
            
            if time.time() > end_time:
               end_time = time.time() + self.time_between_frames
               #self.cmd_send_image(ml, 0.25, 2)
               self.cmd_send_image(ml, self.max_brightness, self.max_gamma)
               
            print counter
            counter += 1

    def cmd_send_image(self, image, brightness, gamma):
        mg_mat = cv.GetMat(image)
        ml_data = self.convert_img_matrix_to_matelight(mg_mat) + "\00\00\00\00"
        data_c = bytearray([int(((x / 255.0) ** (gamma / 100.0)) * 255 * (brightness / 100.0)) for x in list(ml_data)])

        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        sock.sendto(data_c, (IP, PORT))

    def cmd_fps_changed(self, value):
        self.fps = value
        self.time_between_frames = 1.0 / self.fps

    def cmd_red_slider_changed(self, value):
        self.max_red = value
        print "red slider changed to %d %%" % value

    def cmd_green_slider_changed(self, value):
        self.max_green = value
        print "green slider changed to %d %%" % value

    def cmd_blue_slider_changed(self, value):
        self.max_blue = value
        print "blue slider changed to %d %%" % value

    def cmd_gamma_slider_changed(self, value):
        self.max_gamma = value
        print "gamma slider changed to %d %%" % value

    def cmd_brightness_slider_changed(self, value):
        self.max_brightness = value
        print "brightness slider changed to %d %%" % value

        
    def cmd_equalize_changed(self, state):
        self.equalize = state
        print state

    def cmd_browse_file(self):
        self.ui.lineEdit_file_path.setText(QFileDialog.getOpenFileName())

    def send_udp_packet(self, payload):
        self.sock.writeDatagram(payload, QtNetwork.QHostAddress(IP), PORT)


    def on_recv_udp_packet(self):
        print "UDP packet received but ignored. TODO: implement handler."
Пример #20
0
class Scheduler(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()
        self.mygui = Ui_Form()
        self.mygui.setupUi(self)

        self.Week = 0
        self.Year = 0
        self.Mygcal = gcal.gcal()
        self.postes = {}
        self.haschanged = 0
        self.weekdays = []

        self.initialize()

    def bind_radio(self):
        for i in self.weekdays:
            for j in self.postes:
                #print(type(i),type(j))
                eval('self.mygui.radioButton_' + i + '_' + j +
                     '.clicked.connect(self.changed)')

    def changed(self, arg):
        self.haschanged = 1

    def MondayoftheWeek(self, year, week):
        d = datetime.date(year, 1, 1)
        if (d.weekday() > 3):
            d = d + datetime.timedelta(7 - d.weekday())
        else:
            d = d - datetime.timedelta(d.weekday())
        dlt = datetime.timedelta(days=(week - 1) * 7)
        return d + dlt

    def initialize(self):
        self.weekdays = [
            "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi",
            "dimanche"
        ]
        self.get_postes()
        print(self.postes)
        self.thisWeek()
        self.mygui.pushButton_4.clicked.connect(self.nextWeek)
        self.mygui.pushButton_5.clicked.connect(self.prevWeek)
        self.mygui.pushButton.clicked.connect(self.thisWeek)
        self.mygui.pushButton_enregistrer.clicked.connect(self.saveWeekcal)
        self.mygui.pushButton_quitter.clicked.connect(self.close)
        self.bind_radio()

    def get_postes(self):
        with open('postes.txt', 'r') as file:
            self.postes = json.load(file)

    def setWeek(self):

        # Create datetime for each day
        self.lundi = self.MondayoftheWeek(self.Year, self.Week)
        self.mardi = self.lundi + datetime.timedelta(days=1)
        self.mercredi = self.lundi + datetime.timedelta(days=2)
        self.jeudi = self.lundi + datetime.timedelta(days=3)
        self.vendredi = self.lundi + datetime.timedelta(days=4)
        self.samedi = self.lundi + datetime.timedelta(days=5)
        self.dimanche = self.lundi + datetime.timedelta(days=6)

        # Get week number
        actualWeek = self.lundi.isocalendar()[1]
        self.mygui.label_semaine.setText("Semaine " + str(actualWeek))

        # actualize dates on the gui
        self.mygui.label_lundi.setText(self.lundi.strftime("%d %b %Y"))
        self.mygui.label_mardi.setText(self.mardi.strftime("%d %b %Y"))
        self.mygui.label_mercredi.setText(self.mercredi.strftime("%d %b %Y"))
        self.mygui.label_jeudi.setText(self.jeudi.strftime("%d %b %Y"))
        self.mygui.label_vendredi.setText(self.vendredi.strftime("%d %b %Y"))
        self.mygui.label_samedi.setText(self.samedi.strftime("%d %b %Y"))
        self.mygui.label_dimanche.setText(self.dimanche.strftime("%d %b %Y"))

        # load gcalendar
        self.loadWeekcal()

        #print(monday.isoformat())
        #print(self.Mygcal.read(monday))

    def nextWeek(self):
        self.Week += 1
        self.setWeek()

    def prevWeek(self):
        self.Week -= 1
        self.setWeek()

    def thisWeek(self):
        now = datetime.datetime.now()
        self.Year = now.isocalendar()[0]
        self.Week = now.isocalendar()[1]

        self.setWeek()

    def gcal_event(self, day, poste):
        dstart = eval('self.' + day)

        if poste == "nuit":
            dstop = dstart + +datetime.timedelta(days=1)
        else:
            dstop = dstart
        print(poste)
        if poste != "repos":
            gcal_event = {
                'summary':
                self.postes[poste]["nom"],
                'location':
                '',
                'description':
                'Dernière modification :' +
                datetime.datetime.now().strftime("%d/%m/%y"),
                'start': {
                    'dateTime':
                    dstart.isoformat() + 'T' +
                    self.postes[poste]["heure_debut"] + ':00+01:00',
                    'timeZone':
                    'Europe/Paris',
                },
                'end': {
                    'dateTime':
                    dstop.isoformat() + 'T' + self.postes[poste]["heure_fin"] +
                    ':00+01:00',
                    'timeZone':
                    'Europe/Paris',
                },
            }
        else:
            gcal_event = 0
        return gcal_event

    def loadWeekcal(self):
        for i in self.weekdays:
            poste = self.Mygcal.read(eval('self.' + i))
            if poste != 0:
                print(i, poste.lower())
                eval('self.mygui.radioButton_' + i + '_' + poste.lower() +
                     '.setChecked(True)')
            else:
                eval('self.mygui.radioButton_' + i + '_repos.setChecked(True)')

    def saveWeekcal(self):

        for i in self.weekdays:
            self.Mygcal.delete_event(eval('self.' + i))
            for j in self.postes:
                if eval('self.mygui.radioButton_' + i + '_' + j +
                        '.isChecked()'):
                    self.Mygcal.create_event(self.gcal_event(i, j))
                    print(self.gcal_event(i, j))
        self.haschanged = 0

    def closeEvent(self, event):
        reply = QtWidgets.QMessageBox.question(
            self, 'Window Close', 'Are you sure you want to close the window?',
            QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
            QtWidgets.QMessageBox.No)

        if reply == QtWidgets.QMessageBox.Yes:
            event.accept()
            print('Window closed')
        else:
            event.ignore()
Пример #21
0
class JoyUI(QtGui.QDialog):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)