def __init__(self):

        super().__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.show()
        self.getBoards()

        self.ui.comboBoxDirs.currentIndexChanged.connect(self.getConfigs)
        self.ui.comboBoxConfigs.currentIndexChanged.connect(self.loadConfig)
        self.ui.pushButtonLoad.clicked.connect(self.copyConfigs)

        self.getADCThread = GetADCThread()
        self.getADCThread.start()
        self.getADCThread.voltageSignal.connect(
            self.ui.labelVoltageMeasured.setText)
        self.getADCThread.currentSignal.connect(
            self.ui.labelCurrentMeasured.setText)

        self.getADCThread.DeviationCurrentLabel.connect(
            self.ui.CurrentDeviationLabel.setText)
        self.getADCThread.DeviationVoltageLabel.connect(
            self.ui.VoltageDeviationLabel.setText)

        self.getADCThread.pushButtonCurrent.connect(
            self.ui.pushButtonCurrent.setStyleSheet)
        self.getADCThread.pushButtonVoltage.connect(
            self.ui.pushButtonVoltage.setStyleSheet)
        self.getADCThread.pushButtonALL.connect(
            self.ui.pushButtonALL.setStyleSheet)

        self.ui.pushButtonALL.setStyleSheet(
            "border-radius:50px; background-color: rgb(255,0,0);")

        app.processEvents()
class MyForm(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

        self.handler = serialHandler(self.ui)
        self.rxThread_inst = rxThread(self.handler, self.ui)
        # self.dataProc =

    # GUI에서 이벤트에 의한 시그널을 받을 슬롯 함수
    # 해당 이벤트에 대한 함수 호출

    def connectSerial(self):  # 데이터를 요청하는 함수
        if 0 == self.handler.connectSerial():
            self.ui.textEdit.setText("CONNECT SUCCEED!")
            self.rxThread_inst.start()
            # self.dip_inst.start()
        else:
            self.ui.textEdit.setText("CONNECT FAILED!")

    def changedSerialConfig(self):
        self.handler.serialComport = self.ui.comboBox_ComPort.currentIndex()
        self.handler.serialBaudrate = self.ui.comboBox_Baudrate.currentText().toInt()

    def getData(self):  # 데이터를 요청하는 함수
        self.handler.getData("p")

    def saveData(self):
        self.fileName = QtGui.QFileDialog.getSaveFileName(self, "Save File", ".csv")
        self.fname = open(self.fileName, "w")
        self.fname.write(self.ui.textEdit.toPlainText())
        self.fname.close()
Exemple #3
0
def pre_init(core_set_property, core_city_is_avaliable):
    global ui
    global app
    global Dialog

    app = QtWidgets.QApplication(sys.argv)
    Dialog = QtWidgets.QDialog()
    ui = Ui_Dialog()
    ui.setupUi(Dialog, core_set_property, core_city_is_avaliable)
    def __init__(self):
        super().__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

        gwidget = QtWidgets.QWidget(self.ui.graphGroupBox)
        self.graph = Graph()
        layout = QtWidgets.QVBoxLayout(gwidget)
        layout.addWidget(self.graph.canvas)
class ApplicationWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

        gwidget = QtWidgets.QWidget(self.ui.graphGroupBox)
        self.graph = Graph()
        layout = QtWidgets.QVBoxLayout(gwidget)
        layout.addWidget(self.graph.canvas)

    def appendValue(self, value):
        self.graph.append(value)
Exemple #6
0
	def __init__(self, parent=None):
		global info
		QtGui.QWidget.__init__(self, parent)
		self.ui = Ui_Dialog()
		self.ui.setupUi(self)	
		self.leerInfo()
		self.displayInfo()
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

        self.handler = serialHandler(self.ui)
        self.rxThread_inst = rxThread(self.handler, self.ui)
    def __init__(self, parent = None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        
        #Defining the slots and signals
	QtCore.QObject.connect(self.ui.enco, QtCore.SIGNAL("clicked()"), self.encode)
	QtCore.QObject.connect(self.ui.deco, QtCore.SIGNAL("clicked()"), self.decode)
    	QtCore.QObject.connect(self.ui.clear, QtCore.SIGNAL("clicked()"), self.clearall)
Exemple #9
0
    def __init__(self):
        super(TftpDialog, self).__init__()

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

        # Connect the button click signals.
        self.ui.pushButton_Ping.clicked.connect(self.Ping)
        self.ui.pushButton_Clear.clicked.connect(self.ClearLog)
        self.ui.pushButton_Fetch.clicked.connect(self.Fetch)
        self.ui.pushButton_Show.clicked.connect(self.BigShow)
        self.ui.pushButton_FetchShow.clicked.connect(self.FetchAndShow)
        self.ui.pushButton_Manual.clicked.connect(self.Manual)

        # Define the ComboBox content
        self.ui.comboBox_RackNo.addItems(['1', '2', '3'])
        self.ui.comboBox_SlotNo.addItems([
            '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12',
            '13', '14', '15'
        ])
        self.ui.comboBox_CPU.addItems(['A', 'B'])

        # TODO: add items for other Guest Boards.
        self.ui.comboBox_Type.addItems(['PDDM46', 'PDDM5', 'SDDM'])

        # Connect the comboBox select signal
        self.ui.comboBox_Type.currentIndexChanged.connect(
            self.AddItemToFileCombo)

        # TODO: 实例化对象,初始化对象,Connect Guest board with tftp file signal,Connect Log with Guest boards
        self.pddm5 = PDDM5('PDDM5', 1)
        self.pddm5.deviceInit(msgFile=r'./config/pddm5_message.xml',
                              log=r'./log/pddm5.log')
        self.Signal.connect(
            self.pddm5.fileParser)  # 将fetch下来的tftp file文件名传递给Guest board
        self.pddm5.Signal.connect(self.Log)  # 将Guest board需要显示在文本框中的信息传递过来Log

        # SDDM board
        self.sddm = sddm.SDDM()
Exemple #10
0
    def __init__(self):
        super(Main_Form, self).__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.ui.white.installEventFilter(self)
        self.video = False
        self.photo = False
        self.capture = False

        self.play_green = QIcon()
        self.play_green.addPixmap(QPixmap("play-green.svg"), QIcon.Normal,
                                  QIcon.Off)
        self.play_gray = QIcon()
        self.play_gray.addPixmap(QPixmap("play-gray.svg"), QIcon.Normal,
                                 QIcon.Off)

        self.ui.cameraButton.setIcon(self.play_gray)

        self.photoThread = Worker("photo")
        self.photoThread.sinOut.connect(self.photoCallback)

        self.cameraThread = Worker("camera")
        self.cameraThread.sinOut.connect(self.cameraCallback)
        self.ui.cameraButton.clicked.connect(self.cameraButtonClicked)

        self.ui.noseFilters.itemSelectionChanged.connect(
            self.noseFiltersItemSelectionChanged)
        self.ui.eyeFilters.itemSelectionChanged.connect(
            self.eyeFiltersItemSelectionChanged)
        self.ui.earFilters.itemSelectionChanged.connect(
            self.earFiltersItemSelectionChanged)

        self.whiterThread = Whiter(self.ui.white)
        self.ui.captureButton.clicked.connect(self.captureButtonClicked)
        self.ui.white.setAttribute(Qt.WA_TranslucentBackground)
        self.ui.checkBox.clicked.connect(self.checkBoxClicked)

        self.frame_count = 0
        self.lst_time = time.time()
class StartQT4(QtGui.QMainWindow):
    
    def __init__(self, parent = None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        
        #Defining the slots and signals
	QtCore.QObject.connect(self.ui.enco, QtCore.SIGNAL("clicked()"), self.encode)
	QtCore.QObject.connect(self.ui.deco, QtCore.SIGNAL("clicked()"), self.decode)
    	QtCore.QObject.connect(self.ui.clear, QtCore.SIGNAL("clicked()"), self.clearall)
    	
    def encode(self):
    		
    def clearall(self):
    	
    def decode(self):
    	
if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    myapp = StartQT4()
    myapp.show()
    sys.exit(app.exec_())
Exemple #12
0
 def loginGui(self):
     self.ui = Ui_Dialog()
     self.ui.setupUi(self)
     self.ui.Tbl_GPCR.setRowCount(100)
     self.ui.Tbl_GPCR.setItem(0, 0, QtGui.QTableWidgetItem(""))
     self.show()
Exemple #13
0
class StartGUI(QtGui.QDialog):
	def __init__(self, parent=None):
		global info
		QtGui.QWidget.__init__(self, parent)
		self.ui = Ui_Dialog()
		self.ui.setupUi(self)	
		self.leerInfo()
		self.displayInfo()
		
	def leerInfo(self):
		global info
		fname = "/proc/acpi/battery/BAT0/info"
		if not os.path.isfile(fname):

			f= open("/sys/class/power_supply/BAT0/energy_full")
			maxfull = f.readlines()[0]
			f= open("/sys/class/power_supply/BAT0/energy_full_design")
			maxcap = f.readlines()[0]
			f= open("/sys/class/power_supply/BAT0/present")
			present = f.readlines()[0]
			if present == '1\n':
				present = True
			else:
				present = False
			f.close()
			info = (present,maxcap,maxfull)
			return 1

		f = open("/proc/acpi/battery/BAT0/info") #obtenemos la informacion de /proc
		text=f.readlines()
	#	print text
		present = text[0].split(':')[1].strip() #Checkeamos si hay bateria o no 
		if(present=='no'):
			present = False
			info = (present,'','')
			return 0
		else:
			
		#	print present
			maxcap = text[1].split(':')[1].strip().split(' ')[0] #parseamos la capacidad maxima de bateria
		#	print maxcap
			maxfull = text[2].split(':')[1].strip().split(' ')[0] #parseamos la capacidad maxima de la ultima carga
			#maxfull=int(maxfull)
		#	print maxfull
			f.close()
			info = (present,maxcap,maxfull)
			return 1
		
	def displayInfo(self):
		global info
		capacity = float(info[1])/1000000
		full = float(info[2])/1000000
		if(info[0]): #cargamos la informacion en los widgets
			self.ui.lineEdit.setText(str(capacity) + ' Wh')  
			self.ui.lineEdit_2.setText(str(full) + ' Wh') 
			batHealth = (full*100)/capacity # "Calculo" del porcentaje de 'Salud' de la bateria
			#print "%.2f" %  batHealth 
			self.ui.progressBar.setProperty("value", batHealth)
			#self.ui.label_3.setText(str(self.ui.label_3.text()) + str(100-batHealth) + ' %')
			self.ui.label_3.setText("Capacidad perdida: "  + "%.2f" % (100-batHealth) + ' %')
			#self.ui.lineEdit_3.setText(str(batHealth) + ' %')
		else:
			self.ui.lineEdit.setText("NO BAT")
Exemple #14
0
class Main_Form(QDialog):
    # def __del__(self):
    #     super(Main_Form, self).__del__()
    #     self.cameraThread.keep_running = False

    def __init__(self):
        super(Main_Form, self).__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.ui.white.installEventFilter(self)
        self.video = False
        self.photo = False
        self.capture = False

        self.play_green = QIcon()
        self.play_green.addPixmap(QPixmap("play-green.svg"), QIcon.Normal,
                                  QIcon.Off)
        self.play_gray = QIcon()
        self.play_gray.addPixmap(QPixmap("play-gray.svg"), QIcon.Normal,
                                 QIcon.Off)

        self.ui.cameraButton.setIcon(self.play_gray)

        self.photoThread = Worker("photo")
        self.photoThread.sinOut.connect(self.photoCallback)

        self.cameraThread = Worker("camera")
        self.cameraThread.sinOut.connect(self.cameraCallback)
        self.ui.cameraButton.clicked.connect(self.cameraButtonClicked)

        self.ui.noseFilters.itemSelectionChanged.connect(
            self.noseFiltersItemSelectionChanged)
        self.ui.eyeFilters.itemSelectionChanged.connect(
            self.eyeFiltersItemSelectionChanged)
        self.ui.earFilters.itemSelectionChanged.connect(
            self.earFiltersItemSelectionChanged)

        self.whiterThread = Whiter(self.ui.white)
        self.ui.captureButton.clicked.connect(self.captureButtonClicked)
        self.ui.white.setAttribute(Qt.WA_TranslucentBackground)
        self.ui.checkBox.clicked.connect(self.checkBoxClicked)

        self.frame_count = 0
        self.lst_time = time.time()

    def checkBoxClicked(self):
        if not self.video and self.photo:
            self.photoThread.start()

    def captureButtonClicked(self):
        self.whiterThread.start()
        if self.video:
            self.capture = True
        elif self.photo:
            save_image(self.photoThread.data.copy())

    def photoCallback(self):
        self.updatePicture(self.photoThread.data)

    def cameraCallback(self):
        self.frame_count += 1
        self.updatePicture(self.cameraThread.data)
        if self.frame_count == 10:
            print("FPS:", 10.0 / (time.time() - self.lst_time))
            print(selectedFilters)
            self.frame_count = 0
            self.lst_time = time.time()
        if self.capture:
            save_image(self.cameraThread.data.copy())
            self.capture = False

    def cameraButtonClicked(self):
        if self.video:
            self.ui.cameraButton.setIcon(self.play_gray)
            self.cameraThread.keep_running = False
            self.photo = True
            self.photoThread.raw_image = self.cameraThread.raw_image
            self.photoThread.qinding = True
            self.photoThread.data = self.cameraThread.data
        else:
            self.ui.cameraButton.setIcon(self.play_green)
            self.photo = False
            self.cameraThread.keep_running = True
            self.cameraThread.start()
        self.video = not self.video

    def noseFiltersItemSelectionChanged(self):
        if len(self.ui.noseFilters.selectedItems()) == 0:
            selectedFilters.pop("nose")
        else:
            selectedFilters["nose"] = self.ui.noseFilters.selectedItems(
            )[0].name
        if self.photo:
            self.photoThread.start()

    def earFiltersItemSelectionChanged(self):
        if len(self.ui.earFilters.selectedItems()) == 0:
            selectedFilters.pop("ear")
        else:
            selectedFilters["ear"] = self.ui.earFilters.selectedItems()[0].name
        if self.photo:
            self.photoThread.start()

    def eyeFiltersItemSelectionChanged(self):
        if len(self.ui.eyeFilters.selectedItems()) == 0:
            selectedFilters.pop("eye")
        else:
            selectedFilters["eye"] = self.ui.eyeFilters.selectedItems()[0].name
        if self.photo:
            self.photoThread.start()

    def eventFilter(self, source, e):
        if source is self.ui.white:
            if e.type() == QEvent.DragEnter:
                if self.video:
                    e.ignore()
                else:
                    if e.mimeData().hasUrls():
                        if len(e.mimeData().urls()) != 1:
                            e.ignore()
                        else:
                            kind = filetype.guess(
                                e.mimeData().urls()[0].toLocalFile())
                            if kind is None:
                                e.ignore()
                            elif kind.mime[:5] == 'image':
                                e.accept()
                            else:
                                e.ignore()
                    else:
                        e.ignore()
                return True

            if e.type() == QEvent.Drop:
                self.photoThread.qinding = False
                self.video = False
                self.ui.cameraButton.setIcon(self.play_gray)
                self.photoThread.file_name = e.mimeData().urls(
                )[0].toLocalFile()
                self.photo = True
                self.photoThread.run()
                return True

        return QDialog.eventFilter(self, source, e)

    def updatePicture(self, opencv_img):
        if opencv_img.shape[0] != PIC_WIDTH and opencv_img.shape[
                1] != PIC_HEIGHT:
            opencv_img = cv2.resize(opencv_img, (PIC_WIDTH, PIC_HEIGHT),
                                    interpolation=cv2.INTER_LINEAR)
        self.ui.picture.setPixmap(npy2qpm(opencv_img))
    def __init__(self):
        QtWidgets.QDialog.__init__(self)

        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
Exemple #16
0
import sys
from ui import Ui_Dialog
from PySide import QtCore, QtGui
#from Qt import QtWidgets

app = QtGui.QApplication(sys.argv)

Dialog = QtGui.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()


def Plus():
    ui.label.setText('+')


def Minus():
    ui.label.setText('-')


def Multiply():
    ui.label.setText('*')


def Tosplit():
    ui.label.setText('/')


def getResult():
    try:
Exemple #17
0
class TftpDialog(QDialog):
    # Signal used to send the tftp file name to the guest boards.
    Signal = QtCore.pyqtSignal(str, str)  # board type + tftp file name

    def __init__(self):
        super(TftpDialog, self).__init__()

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

        # Connect the button click signals.
        self.ui.pushButton_Ping.clicked.connect(self.Ping)
        self.ui.pushButton_Clear.clicked.connect(self.ClearLog)
        self.ui.pushButton_Fetch.clicked.connect(self.Fetch)
        self.ui.pushButton_Show.clicked.connect(self.BigShow)
        self.ui.pushButton_FetchShow.clicked.connect(self.FetchAndShow)
        self.ui.pushButton_Manual.clicked.connect(self.Manual)

        # Define the ComboBox content
        self.ui.comboBox_RackNo.addItems(['1', '2', '3'])
        self.ui.comboBox_SlotNo.addItems([
            '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12',
            '13', '14', '15'
        ])
        self.ui.comboBox_CPU.addItems(['A', 'B'])

        # TODO: add items for other Guest Boards.
        self.ui.comboBox_Type.addItems(['PDDM46', 'PDDM5', 'SDDM'])

        # Connect the comboBox select signal
        self.ui.comboBox_Type.currentIndexChanged.connect(
            self.AddItemToFileCombo)

        # TODO: 实例化对象,初始化对象,Connect Guest board with tftp file signal,Connect Log with Guest boards
        self.pddm5 = PDDM5('PDDM5', 1)
        self.pddm5.deviceInit(msgFile=r'./config/pddm5_message.xml',
                              log=r'./log/pddm5.log')
        self.Signal.connect(
            self.pddm5.fileParser)  # 将fetch下来的tftp file文件名传递给Guest board
        self.pddm5.Signal.connect(self.Log)  # 将Guest board需要显示在文本框中的信息传递过来Log

        # SDDM board
        self.sddm = sddm.SDDM()

    def AddItemToFileCombo(self):
        self.ui.comboBox_Name.clear()

        # TODO: add ftp_* for other Guest Board.
        if self.ui.comboBox_Type.currentText() == 'PDDM5':
            self.ui.comboBox_Name.addItems(
                ['ftp_vers', 'ftp_phase', 'ftp_volt', 'ftp_indi', 'ftp_err'])
        elif self.ui.comboBox_Type.currentText() == 'PDDM46':
            self.ui.comboBox_Name.addItems(
                ['ftp_vers', 'ftp_cur', 'ftp_indi', 'ftp_err'])
        elif self.ui.comboBox_Type.currentText() == 'SDDM':
            self.ui.comboBox_Name.addItems(['ftp_cur', 'ftp_vers'])

    def IPCheck(self, key):
        pattern = "\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"
        if re.match(pattern, key) != None:
            return True
        else:
            return False

    def Ping(self):
        # Check if the ip address is valid
        if self.IPCheck(self.ui.lineEdit_IP.text()) == True:
            # Check platform
            if sys.platform.find("linux") == 0:
                child = subprocess.Popen(
                    ["ping", "-c", "4",
                     self.ui.lineEdit_IP.text()],
                    stdout=subprocess.PIPE)
            else:
                child = subprocess.Popen(
                    ["ping", "-n", "4",
                     self.ui.lineEdit_IP.text()],
                    stdout=subprocess.PIPE)
            output = child.stdout.read()
            self.Log(output)
            child.terminate()
        else:
            self.Log("Ilegal IP: {0}".format(self.ui.lineEdit_IP.text()))

    def Fetch(self):
        rack = int(self.ui.comboBox_RackNo.currentText())
        slot = int(self.ui.comboBox_SlotNo.currentText())
        cpu = self.ui.comboBox_CPU.currentText()
        ip = self.ui.lineEdit_IP.text()
        file = self.ui.comboBox_Name.currentText()

        # Check IP valid
        if self.IPCheck(ip) == False:
            self.Log("Ilegal IP: {0}".format(self.ui.lineEdit_IP.text()))
            return -1

        # Enable the routing to the corresponding Guest board.
        status, copopen_errinfo = cop.CopOpen(rack, slot, cpu, ip)

        if status != 0:
            self.Log('copopen status: ' + str(status) + ', errinfo: ' +
                     copopen_errinfo)
        else:
            self.Log('copopen status: ' + str(status))
            # DownLoad the tftp file.
            status, download_errinfo = tftplib.Tftplib_Download(
                rack, slot, cpu, file, ip)
            if status == 0:
                self.Log('download status: ' + str(status))
            else:
                self.Log('download status: ' + str(status) + ', errinfo: ' +
                         download_errinfo)
        return status

    def BigShow(self):
        fileName = QFileDialog.getOpenFileName()
        self.Log(fileName[0])
        self.Show(fileName[0])

    def Show(self, file):
        board = self.ui.comboBox_Type.currentText()
        rack = int(self.ui.comboBox_RackNo.currentText())
        slot = int(self.ui.comboBox_SlotNo.currentText())
        cpu = self.ui.comboBox_CPU.currentText()

        if os.path.isfile(file):
            if board == 'SDDM':
                (status, show_err) = self.sddm.show(rack, slot, cpu, file)
                self.Log('Show status: ' + str(status) + ', info: \n' +
                         show_err)
            else:
                self.Signal.emit(board, file)
        else:
            self.Log(file + ' is not exist.')

    def FetchAndShow(self):
        if self.Fetch() == 0:
            self.Show(self.ui.comboBox_Name.currentText())

    def Log(self, str):
        self.ui.textEdit_Log.append(
            time.asctime(time.localtime(time.time())) + ' ---- \n' + str)

    def ClearLog(self):
        self.ui.textEdit_Log.clear()

    def Manual(self):
        self.Log('Manual is unavailable...')
class AqHandlerWindow(QtWidgets.QDialog):
    crashExcCodes = {'ServerConnectionError': 'SCF404',
                     'Other': 'UND000'}

    def __init__(self):
        QtWidgets.QDialog.__init__(self)

        self.ui = Ui_Dialog()
        self.ui.setupUi(self)


    def handle(self):
        self.crashLocation = sys.argv[1]
        self.crashReportAddress = sys.argv[2]
        self.crashExcCode = sys.argv[3]
        self.crashedSessionLogFileAddr = sys.argv[4]
        self.crashData = sys.argv[5:]

        if self.crashExcCode in self.crashExcCodes.values():
            if self.crashExcCode == self.crashExcCodes['ServerConnectionError']:
                self.setMaximumSize(400, 230)

                self.ui.lnI_lineEdit.show()
                self.ui.lbl_lineEditTitle.show()
                
                self.ui.lbl_ErrorTitle.setText('Не удалось подключиться к серверу')
                self.ui.lbl_ErrorDesc.setText(f'Сервер по адресу {self.crashData[0]} недоступен. Проверьте, что сервер запущен, что он работает без ошибок; '
                                               'попробуйте перезапустить его.\n\n'
                                               'Также, пожауйста, перепровepьте и укажите верный адрес сервера в поле ниже:')
                self.ui.lbl_lineEditTitle.setText('Адрес сервера:')
                self.ui.lnI_lineEdit.setPlaceholderText('{адрес} или {адрес}:{порт}')

                self.accepted.connect( lambda: self.finish(self.crashExcCodes['ServerConnectionError']) )


            elif self.crashExcCode == self.crashExcCodes['Other']:
                self.setMaximumSize(400, 195)
                
                self.ui.lnI_lineEdit.hide()
                self.ui.lbl_lineEditTitle.hide()

                self.ui.lbl_ErrorTitle.setText('Произошла непредвиденная ошибка')
                self.ui.lbl_ErrorDesc.setText(f'Непревиденная ошибка привела к аварийному прекращению работы {self.crashLocation}. Пожалуйста, помогите '
                                               'нам решить эту проблему: отправьте отчёт об ошибке, нажав Отправить.')

                self.ui.btn_OpenCrashReport.clicked.connect( lambda: self.openCrashReport() )
                self.ui.btn_OpenSessionLog.clicked.connect( lambda: self.openSessionLog() )

                self.accepted.connect( lambda: self.finish(self.crashExcCodes['Other']) )
                self.rejected.connect( lambda: sys.exit() )


            try:
                with open(f'{os.getcwd()}/{self.crashedSessionLogFileAddr}', 'r') as log: pass
            except FileNotFoundError: self.ui.btn_OpenSessionLog.setEnabled(False)

        else: sys.exit()

    
    @staticmethod
    def decryptContent(s):
        return (base64.b64decode(s.encode('utf-8'))).decode('utf-8')

    
    @staticmethod
    def encryptContent(s):
        return (base64.b64encode(s.encode('utf-8'))).decode('utf-8')


    def openCrashReport(self):
        os.startfile(f'{os.getcwd()}/{self.crashReportAddress}')


    def openSessionLog(self):
        os.startfile(f'{os.getcwd()}/{self.crashedSessionLogFileAddr}')


    def finish(self, exceptionCode):
        if exceptionCode == self.crashExcCodes['ServerConnectionError']:
            if not self.ui.lnI_lineEdit.text(): sys.exit()
            else:
                with open('data/config/~!serverdata!~.asqd', 'r') as configFile:
                    fileString = self.decryptContent(configFile.read())

                with open('data/config/~!serverdata!~.asqd', 'w') as configFile: 
                    jsonString = json.loads(fileString)
                    address = self.ui.lnI_lineEdit.text().split(':')
                    if len(address) == 2: jsonString['ip'], jsonString['port'] = address[0], int(address[1])
                    else: jsonString['ip'], jsonString['port'] = address[0], None

                    configFile.write(self.encryptContent(json.dumps(jsonString)))

            sys.exit()

        else: sys.exit()


    def mainloop(self, app: QtWidgets.QApplication):
        self.show()
        sys.exit(app.exec_())
Exemple #19
0
 def __init__(self):
     QObject.__init__(self)
     Ui_Dialog.__init__(self)
Exemple #20
0
from ui import Ui_Dialog
import sys
from PyQt4.QtGui import QApplication, QDialog

app = QApplication(sys.argv)
window = QDialog()
ui = Ui_Dialog()
ui.setupUi(window)

window.show()
sys.exit(app.exec_())
Exemple #21
0
class Apptt(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.loginGui()

    def loginGui(self):
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.ui.Tbl_GPCR.setRowCount(100)
        self.ui.Tbl_GPCR.setItem(0, 0, QtGui.QTableWidgetItem(""))
        self.show()

    @QtCore.pyqtSlot(int)
    def browsefile(self):
        self.ui.Ln_Filename.setText(
            QtGui.QFileDialog.getOpenFileName(self, "open file", " ",
                                              "PDB file(*.pdb);;Allfile(*.*)"))

        file = open(self.ui.Ln_Filename.text())
        title = ""
        author = ""
        num = 0
        while True:
            line = file.readline()

            if not line:
                break

            if line.find("AUTHOR") != -1:
                line = line.strip()
                print line
                author = author + line[10:]
                self.ui.Tbl_GPCR.setItem(0, 3, QtGui.QTableWidgetItem(line))

            if line.find("HEADER") != -1:
                num = line.index("-")
                self.ui.Tbl_GPCR.setItem(
                    0, 4, QtGui.QTableWidgetItem(line[num - 2:num + 7]))

            if line[0:5] == "TITLE":
                line = line.strip()
                title = title + line[10:]
                self.ui.Tbl_GPCR.setItem(0, 1, QtGui.QTableWidgetItem(title))

            if line[12:15] == "REF":
                line = line.strip()
                jounal = jounal + line[19:]
                self.ui.Tbl_GPCR.setItem(0, 2, QtGui.QTableWidgetItem(jounal))

            if line[0:6] == "EXPDTA":
                line = line.strip()
                method = method + line[10:]
                self.ui.Tbl_GPCR.setItem(0, 8, QtGui.QTableWidgetItem(method))

            if line[11:22] == "RESOLUTION.":
                line = line.strip()
                resolution = resolution + line[26:]
                self.ui.Tbl_GPCR.setItem(0, 9,
                                         QtGui.QTableWidgetItem(resolution))

            if line[13:47] == "R VALUE     (WORKING + TEST SET) :":
                line = line.strip()
                r_value = r_value + line[48:]
                self.ui.Tbl_GPCR.setItem(0, 10,
                                         QtGui.QTableWidgetItem(r_value))

            if line[13:26] == "PROTEIN ATOMS":
                line = line.strip()
                protein_num = protein_num + line[40:]
                self.ui.Tbl_GPCR.setItem(0, 1,
                                         QtGui.QTableWidgetItem(protein_num))

    @QtCore.pyqtSlot(int)
    def submitdata(self):
        self.ui.Ln_Filename.setText(
            QtGui.QFileDialog.getOpenFileName(self, "open file", " ",
                                              "PDB file(*.pdb);;Allfile(*.*)"))
class AppWindow(QDialog):
    def __init__(self):

        super().__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.show()
        self.getBoards()

        self.ui.comboBoxDirs.currentIndexChanged.connect(self.getConfigs)
        self.ui.comboBoxConfigs.currentIndexChanged.connect(self.loadConfig)
        self.ui.pushButtonLoad.clicked.connect(self.copyConfigs)

        self.getADCThread = GetADCThread()
        self.getADCThread.start()
        self.getADCThread.voltageSignal.connect(
            self.ui.labelVoltageMeasured.setText)
        self.getADCThread.currentSignal.connect(
            self.ui.labelCurrentMeasured.setText)

        self.getADCThread.DeviationCurrentLabel.connect(
            self.ui.CurrentDeviationLabel.setText)
        self.getADCThread.DeviationVoltageLabel.connect(
            self.ui.VoltageDeviationLabel.setText)

        self.getADCThread.pushButtonCurrent.connect(
            self.ui.pushButtonCurrent.setStyleSheet)
        self.getADCThread.pushButtonVoltage.connect(
            self.ui.pushButtonVoltage.setStyleSheet)
        self.getADCThread.pushButtonALL.connect(
            self.ui.pushButtonALL.setStyleSheet)

        self.ui.pushButtonALL.setStyleSheet(
            "border-radius:50px; background-color: rgb(255,0,0);")

        app.processEvents()

    def loadConfig(self):
        if self.ui.comboBoxConfigs.currentText() is not "":
            configPATH = os.path.join(
                os.path.join(ConfigDirectory,
                             self.ui.comboBoxDirs.currentText()),
                self.ui.comboBoxConfigs.currentText()) + '.config'
            with open(configPATH, 'r') as file:
                config = file.read()

            config = json.loads(config)
            global CurrentBase, CurrentTolerance, VoltageBase, VoltageTolerance, AdditionalInfo

            CurrentBase = config["CurrentBase"]
            CurrentTolerance = config["CurrentTolerance"]

            VoltageBase = config["VoltageBase"]
            VoltageTolerance = config["VoltageTolerance"]

            AdditionalInfo = config['AdditionalInfo']

            self.ui.labelAdditionalInfo.setText(AdditionalInfo)
            self.ui.labelSetCurrentTo.setText(f'{format(CurrentBase, ".2f")}')
            self.ui.labelSetVoltageTo.setText(f'{format(VoltageBase, ".2f")}')

    def copyConfigs(self):
        shutil.rmtree(ConfigDirectory, ignore_errors=True)
        for item in os.listdir(remoteConfigDirectory):
            shutil.copytree(remoteConfigDirectory, ConfigDirectory)
        self.getBoards()

    def getConfigs(self):
        self.ui.comboBoxConfigs.clear()
        self.ui.comboBoxConfigs.addItem(
            "")  # to make sure user selects a config!
        for file in os.listdir(
                os.path.join(ConfigDirectory,
                             self.ui.comboBoxDirs.currentText())):
            if file.endswith(".config"):
                self.ui.comboBoxConfigs.addItem(file[:-7])

    def getBoards(self):
        self.ui.comboBoxDirs.clear()
        self.ui.comboBoxDirs.addItem("")  # to make sure user selects a board!
        for file in os.listdir(ConfigDirectory):
            if os.path.isdir(os.path.join(ConfigDirectory, file)):
                self.ui.comboBoxDirs.addItem(file)