def llenarListas(self):
        if self.modelSugerencias.rowCount() > 0:
            self.modelSugerencias.removeRows(0,
                                             self.modelSugerencias.rowCount())
        percent = int(self.ui.spnPorcentaje.value())
        estado = "_"
        if (self.ui.chkNuevo.isChecked()
                and (not self.ui.chkUsado.isChecked())):
            estado = "nuevo"
        elif ((not self.ui.chkNuevo.isChecked())
              and self.ui.chkUsado.isChecked()):
            estado = "usado"
        else:
            estado = "_"

        libros, combinaciones = final.regla3(prologa, estado, percent)
        if (len(libros) == 0):
            error_dialog = QErrorMessage(self)
            error_dialog.showMessage('No existen libros con estos parametros')
            error_dialog.exec_()
        else:
            for combo in combinaciones:
                combineshan = QtGui.QStandardItem(
                    "Combinacion " + str(combinaciones.index(combo)))
                for book in combo:
                    print(book)
                    item = QtGui.QStandardItem(str(book))
                    combineshan.appendRow(item)
                if combo.__len__() > 0:
                    self.modelSugerencias.appendRow(combineshan)
            self.ui.pbAdd.setEnabled(True)
            self.ui.pbRemove.setEnabled(True)
            self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(True)
    def cipher_text_decryption(self):
        mul_key = int(self.l2.text())
        sub_key = int(self.l3.text())
        cipher_text = self.l4.text()
        alphabetic = self.l1.text()
        alphabetic = self.remove_duplicates(alphabetic)
        n = len(alphabetic)
        alphabetic = [i for i in alphabetic]
        plain_text = []
        if self.gcd(mul_key, len(alphabetic)) == 1:
            for i in cipher_text:
                # digit = self.inverse(mul_key, n, n) * (alphabetic.index(i)-sub_key) % n
                inverse = self.multiplicative_inverse(mul_key, len(alphabetic))
                digit = (inverse * (alphabetic.index(i) - sub_key)) % n
                if digit < 0:
                    digit += len(alphabetic)
                plain_text.append(alphabetic[digit])

            plain_text = ''.join(plain_text)
            return self.output.setText(plain_text)
        else:
            error_dialog_2 = QErrorMessage()
            error_dialog_2.showMessage('The multiplication factor '
                                       'and the number of alphabets'
                                       ' are not relatively prime')
            error_dialog_2.exec_()
示例#3
0
    def add_items(self):
        try:
            pedido, n_simafic, qtd_items = self.pedido.text(
            ), self.n_simafic.text(), self.qtd_items.text()
            print("Add Pedido: {} {} {}".format(pedido, n_simafic, qtd_items))
            if services.validateCadastro(pedido, n_simafic, qtd_items):
                print("Add Pedido: {} {} {}".format(pedido, n_simafic,
                                                    qtd_items))
                mb = QMessageBox()
                mb.setIconPixmap(QPixmap('assets/check_icon_blue2'))
                mb.setWindowTitle("Sucesso")
                mb.setText(
                    'O pedido: {} foi criado com sucesso!'.format(pedido))
                services.add_pedido(pedido, n_simafic, qtd_items)
                mb.exec_()
                self.update_model_tableview()
                self.limpar_pedidos()

        except (ValidationError, DBPedidosException) as error:
            error_dialog = QErrorMessage()
            error_dialog.setWindowTitle(error.errors)
            error_dialog.setWindowIcon(QIcon(main_icon))
            error_dialog.showMessage(error.message)
            error_dialog.exec_()

        pass
示例#4
0
    def sendToHW(self):
        """
        Select which commands to send the hardware.
        """
        if self.serial.isOpen():
            sender = self.sender()
            if sender == self.btn_Send:
                sendstring = self.lineEdit_InOut.text()
            elif sender == self.btn_EnDisableServo:
                if sender.text() == "Enable":
                    sendstring = "E1"
                    sender.setText("Disable")
                else:
                    sendstring = "E2"
                    sender.setText("Enable")
            else:
                sendstring = sender.text()

            self.sendCommands(sendstring)
        else:
            err = "Please open Serial Port first!"
            print(err)
            error_dialog = QErrorMessage()
            error_dialog.showMessage(err)
            error_dialog.exec_()
        pass
示例#5
0
 def validaScanInput(self):
     print('validaScanInput {}'.format(self.input_scanner.text()))
     try:
         if services.valida_simafic(s_input=self.input_scanner.text(),
                                    pedido=self.pedido):
             self.pedido.qty_scanneada += 1
             self.qtd_parcial_le.setText(str(self.pedido.qty_scanneada))
             self.pedido.nome_responsavel = self.count_resp_le.text()
             self.pedido.id_caixa = self.id_caixa_le.text()
             services.update_pedido(self.pedido)
             self.input_scanner.clear()
             if (self.pedido.qty_scanneada == self.pedido.qty_total):
                 print("Aqui é pra tocar o som")
                 QSound.play('assets/error.wav')
                 self.input_scanner.setDisabled(True)
                 QMessageBox.warning(
                     self, "Item finalizado.",
                     "O Item já atingiu a quantidade cadastrada.")
     except (ValidationError, DBPedidosException) as error:
         error_dialog = QErrorMessage()
         errorSound = QSound('assets/error.wav')
         errorSound.play()
         error_dialog.setWindowTitle(error.errors)
         error_dialog.setWindowIcon(QIcon(main_icon))
         error_dialog.showMessage(error.message)
         self.input_scanner.clear()
         error_dialog.exec_()
示例#6
0
    def connect_to_serial(self):
        #Connect to the Teensy using a serial port. This will be different for everyone
        #Mac computers will us /dev/tty*
        #The Arduino Software can tell you what your com port is.

        # See http://pyserial.readthedocs.io/en/latest/tools.html
        available_ports = sorted(serial.tools.list_ports.comports(),
                                 reverse=True)

        port_choices = []
        for p in available_ports:
            if "16C0" in p.hwid:  #This identifies a Teensy
                port_choices.append("{}: {}".format(p.device, p.description))

        # Open a dialog box to get the COM port.
        com_port_text, ok = QInputDialog.getItem(self, 'Select Serial Port',
                                                 'Available Ports:',
                                                 port_choices, 0, False)

        if ok and com_port_text:
            #extract just the device string
            self.comport = com_port_text.split(":")[0]
            # This code runs when the user has selected a COM port.
            # Use a try-except block to help troubleshoot connectivity problems.
            try:
                self.ser = serial.Serial(self.comport)
                self.statusBar().showMessage(self.comport)
            except Exception as e:
                error_dialog = QErrorMessage()
                error_dialog.showMessage(repr(e))
                error_dialog.exec_()
        else:
            self.statusBar().showMessage("Serial Port Not Connected.")
    def llenarListas(self):
        condicion = "_"

        if (self.ui.cbxCondicion.currentText() == "Nuevos"):
            condicion = "nuevo"
        elif (self.ui.cbxCondicion.currentText() == "Usados"):
            condicion = "usado"
        if self.modelSugerencias.rowCount() > 0:
            self.modelSugerencias.removeRows(0,
                                             self.modelSugerencias.rowCount())
        libros, combinaciones = final.regla6(prologa, condicion,
                                             self.ui.spnCosto.value())
        if (len(libros) == 0):
            error_dialog = QErrorMessage(self)
            error_dialog.showMessage('No existen libros con estos parametros')
            error_dialog.exec_()
        else:
            for combo in combinaciones:
                combineshan = QtGui.QStandardItem(
                    "Combinacion " + str(combinaciones.index(combo)))
                for book in combo:
                    print(book)
                    item = QtGui.QStandardItem(str(book))
                    combineshan.appendRow(item)
                if combo.__len__() > 0:
                    self.modelSugerencias.appendRow(combineshan)
            self.ui.pbAdd.setEnabled(True)
            self.ui.pbRemove.setEnabled(True)
            self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(True)
    def llenarListas(self):
        if self.modelSugerencias.rowCount() > 0:
            self.modelSugerencias.removeRows(0,
                                             self.modelSugerencias.rowCount())

        percentSueldo = int(self.ui.spnPorcentajeSueldo.value())
        autor = self.ui.txtAutor.text()
        categoria = self.ui.cbxCategoria.currentText()
        frase = self.ui.linePalabra.text()

        libros, combinaciones = final.regla4(prologa, percentSueldo, autor,
                                             categoria, frase)

        if (len(libros) == 0):
            error_dialog = QErrorMessage(self)
            error_dialog.showMessage('No existen libros con estos parametros')
            error_dialog.exec_()
        else:
            for combo in combinaciones:
                combineshan = QtGui.QStandardItem(
                    "Combinacion " + str(combinaciones.index(combo)))
                for book in combo:
                    print(book)
                    item = QtGui.QStandardItem(str(book))
                    combineshan.appendRow(item)
                if combo.__len__() > 0:
                    self.modelSugerencias.appendRow(combineshan)
            self.ui.pbAdd.setEnabled(True)
            self.ui.pbRemove.setEnabled(True)
            self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(True)
 def connection_error(self, error):
     self.timer.stop()
     error_dialog = QErrorMessage()
     error_dialog.setWindowTitle('Unable to connect to discord')
     error_dialog.showMessage(error)
     error_dialog.exec_()
     sys.exit(1)
    def llenarListas(self):
        if self.modelSugerencias.rowCount() > 0:
            self.modelSugerencias.removeRows(0,
                                             self.modelSugerencias.rowCount())
        dias = int(self.ui.spnDias.value())
        libros, combinaciones = final.regla1(prologa, final.getClavo(prologa),
                                             dias)
        if (len(libros) == 0):
            error_dialog = QErrorMessage(self)
            error_dialog.showMessage('No existen libros con estos parametros')
            error_dialog.exec_()
        else:
            for combo in combinaciones:
                combineshan = QtGui.QStandardItem(
                    "Combinacion " + str(combinaciones.index(combo)))
                for book in combo:
                    print(book)
                    item = QtGui.QStandardItem(str(book))
                    combineshan.appendRow(item)
                if combo.__len__() > 0:
                    self.modelSugerencias.appendRow(combineshan)

            self.ui.pbAdd.setEnabled(True)
            self.ui.pbRemove.setEnabled(True)
            self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(True)
示例#11
0
 def readContours(self):
     """Reads contours saved in xml format (Echoplaque compatible)"""
     if self.image == False:
         warning = QErrorMessage()
         warning.setWindowModality(Qt.WindowModal)
         warning.showMessage(
             'Reading of contours failed. Images must be loaded prior to loading contours'
         )
         warning.exec_()
     else:
         options = QFileDialog.Options()
         options |= QFileDialog.DontUseNativeDialog
         fileName, _ = QFileDialog.getOpenFileName(
             self,
             "QFileDialog.getOpenFileName()",
             "",
             "XML file (*.xml)",
             options=options)
         self.lumen, self.plaque, self.stent, self.resolution, frames = read_xml.read(
             fileName)
         self.lumen = self.mapToList(self.lumen)
         self.plaque = self.mapToList(self.plaque)
         self.stent = self.mapToList(self.stent)
         self.contours = True
         self.resizeContours()
         self.wid.setData(self.lumen, self.plaque, self.images)
         self.hideBox.setChecked(False)
示例#12
0
    def openSerial(self):
        """
        Tries to open the serial port with the specified parameters. 
        """
        baud = int(self.combo_Baud.currentText())
        COM = self.combo_COM.currentText()
        msg = "Connecting to {} with {} baud and 0.1 timeout.".format(
            COM, baud)
        self.addLogEntry(msg)
        try:
            self.serial.baudrate = baud
            self.serial.port = COM
            self.serial.timeout = 0.1
            self.serial.open()
            # time.sleep(2) # may be necessary if the user is too fast to send commands after opening the port due to the Arduino resetting after establishing connection
            test = self.sendCommands("E1")
            if test == 0:
                self.statusbar.showMessage("Serial connected!")
                msg = "Send command: {}".format(num)
                self.addLogEntry(msg)
        except Exception as err:
            self.statusbar.showMessage("Serial connection failed!")
            msg = "Could not establish serial connection!"
            self.addLogEntry(msg)
            print(err)
            error_dialog = QErrorMessage()
            error_dialog.showMessage(err.args[0])
            error_dialog.exec_()

        pass
    def llenarListas(self):
        if self.modelSugerencias.rowCount() > 0:
            self.modelSugerencias.removeRows(0,
                                             self.modelSugerencias.rowCount())
        fecha = self.ui.dateAntesDe.date()

        anio = fecha.year()
        print(anio)
        autor = self.ui.lineAutor.text()

        libros, combinaciones = final.regla8(prologa, autor,
                                             self.ui.spnPrecio.value(),
                                             str(anio))
        if (len(libros) == 0):
            error_dialog = QErrorMessage(self)
            error_dialog.showMessage('No existen libros con estos parametros')
            error_dialog.exec_()
        else:
            for combo in combinaciones:
                combineshan = QtGui.QStandardItem(
                    "Combinacion " + str(combinaciones.index(combo)))
                for book in combo:
                    print(book)
                    item = QtGui.QStandardItem(str(book))
                    combineshan.appendRow(item)
                if combo.__len__() > 0:
                    self.modelSugerencias.appendRow(combineshan)
            self.ui.pbAdd.setEnabled(True)
            self.ui.pbRemove.setEnabled(True)
            self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(True)
示例#14
0
    def generateSolution(self):
        """
        Generate a solution for the current cubestring and display in the GUI
        """
        self.statusbar.showMessage("Generating Solution")
        msg = "Generating solution for cubestring: " + self.cube.cubestring
        self.addLogEntry(msg)

        timer = QElapsedTimer()
        timer.start()
        solution = "No Solution"
        try:
            solution = kociemba.solve(self.cube.cubestring)
        except Exception as err:
            print(err)
            error_dialog = QErrorMessage()
            error_dialog.showMessage(err.args[0])
            error_dialog.exec_()
            solution = err.args[0]
            self.statusbar.showMessage("Solution generation failed!")
            msg = "Solution could not be calculated: " + solution
            self.addLogEntry(msg)

        self.lineEdit_InOut.setText(solution)
        self.label_CurrentString.setText("Solution:")
        self.statusbar.showMessage("Generated Solution")
        msg = "Solution calculation took: {} ms".format(timer.nsecsElapsed() /
                                                        1000000)
        self.addLogEntry(msg)

        # self.timer1ms.stop()
        pass
示例#15
0
    def create_players(self) -> None:
        """ check the names fields, open the game screen """

        players = {}

        if self.names_screen.player_colors == []:
            for i in range(len(self.names_screen.player_names)):
                self.names_screen.player_colors.append("#FFFFFF")

        for player, color in zip(self.names_screen.player_names,
                                 self.names_screen.player_colors):
            name = player.text().strip()

            if name == "":
                error = QErrorMessage()
                error.showMessage("Please give all players names")
                error.exec_()
                return
            else:
                names = [player.get_name() for player in players]

                if name in names:
                    error = QErrorMessage()
                    error.showMessage("2 players can't have the same name")
                    error.exec_()
                    return

            players[Player(name)] = color

        self.game = Monopoly(players, self.debug)
        self.central_widget.addWidget(self.game)
        self.central_widget.setCurrentWidget(self.game)
示例#16
0
 def DrawDia(self):
     if count_code != 0:
         fig_Dia = self.newCount.makeDiagram()
         self.showDiagram(fig_Dia)
     else:
         error_dialog = QErrorMessage()
         error_dialog.showMessage('Сначала рассчитайте конструкцию!')
         error_dialog.exec_()
示例#17
0
 def onIPAddressChanged(self):
     ip = self.sender().text()
     logger.debug("JoggerDialog.onIPAddressChanged(text={})".format(ip))
     if not isValidIPAddress(ip):
         msg = QErrorMessage(self)
         msg.showMessage("Invalid IP address")
         msg.exec_()
         self.sender().setFocus()
示例#18
0
 def segment(self):
     """Segmentation and phenotyping of IVUS images"""
     warning = QErrorMessage()
     warning.setWindowModality(Qt.WindowModal)
     warning.showMessage(
         'Warning: IVUS Phenotyping is currently only supported for 20MHz images. Interpret other images with extreme caution'
     )
     warning.exec_()
示例#19
0
    def downloadModuleFailed(self, module):
        self.failed_protocol.append(module)
        print(self.failed_protocol)

        qerror = QErrorMessage()
        qerror.showMessage('Installation Failed: ' + module['name'] +
                           ' from Repository ' + module['repository'])
        qerror.exec_()
示例#20
0
 def onPortChanged(self):
     port = self.sender().text()
     logger.debug("JoggerDialog.onPortChanged(text={})".format(port))
     if not isValidPortNumber(port):
         msg = QErrorMessage(self)
         msg.showMessage("Invalid port number")
         msg.exec_()
         self.sender().setFocus()
示例#21
0
 def oepn_file(self):
     filename = QFileDialog.getOpenFileName(self, 'Open file', os.getcwd())[0]
     try:
         self.book = AccountBook(filename)
         self.update_data()
     except:
         err = QErrorMessage()
         err.showMessage("Open {} failed. {}".format(filename, sys.exc_info()[1]))
         err.exec_()
示例#22
0
 def setPropertyForAllObjects(self):
     selectedPropertyIndices = self.selectedColumns() if self.model(
     ).isRowObjects else self.selectedRows()
     if len(selectedPropertyIndices) != 1:
         errorDialog = QErrorMessage(self)
         rowOrColumn = "column" if self.model().isRowObjects else "row"
         errorDialog.showMessage("Must select a single property " +
                                 rowOrColumn + ".")
         errorDialog.exec_()
         return
     try:
         propertyIndex = selectedPropertyIndices[0]
         dtype = self.model().propertyType(propertyIndex)
         if dtype is None:
             return
         obj = self.model().objects[0]
         prop = self.model().properties[propertyIndex]
         if "Write" not in prop.get('mode', "Read/Write"):
             return
         model = ObjListTableModel([obj], [prop],
                                   self.model().isRowObjects, False)
         view = ObjListTable(model)
         dialog = QDialog(self)
         buttons = QDialogButtonBox(QDialogButtonBox.Ok)
         buttons.accepted.connect(dialog.accept)
         buttons.rejected.connect(dialog.reject)
         vbox = QVBoxLayout(dialog)
         vbox.addWidget(view)
         vbox.addWidget(buttons)
         dialog.setWindowModality(Qt.WindowModal)
         dialog.exec_()
         for objectIndex, obj in enumerate(self.model().objects):
             row = objectIndex if self.model(
             ).isRowObjects else propertyIndex
             col = propertyIndex if self.model(
             ).isRowObjects else objectIndex
             index = self.model().index(row, col)
             if objectIndex == 0:
                 value = self.model().data(index)
             else:
                 if prop.get('action', '') == "fileDialog":
                     try:
                         getAttrRecursive(obj, prop['attr'])(value)
                         self.model().dataChanged.emit(
                             index,
                             index)  # Tell model to update cell display.
                     except:
                         self.model().setData(index, value)
                         self.model().dataChanged.emit(
                             index,
                             index)  # Tell model to update cell display.
                 else:
                     self.model().setData(index, value)
                     self.model().dataChanged.emit(
                         index, index)  # Tell model to update cell display.
     except:
         pass
 def open_pca_window(self):
     if len(self.raman_datasets) > 0:
         self.raman_pca_window = raman_pca_window(self.active_dataset())
         self.raman_pca_window.show()
     else:
         error_message = QErrorMessage()
         error_message.showMessage('No active dataset available to '
                                   'analyze!')
         error_message.exec_()
示例#24
0
 def show_error_message(self, error_message):
     """
     负责弹出错误消息框
     :param error_message: 消息框里面的内容
     :return: None
     """
     error = QErrorMessage()
     error.showMessage(error_message)
     error.exec_()
示例#25
0
 def GoCount(self):
     if len(json_dict) != 0:
         self.newCount.Counting_init(json_dict)
         global count_code
         count_code = 1
     else:
         error_dialog = QErrorMessage()
         error_dialog.showMessage('Сначала сохраните файл характеристик!')
         error_dialog.exec_()
    def show_reject_file_message(self, error_msg):
        '''
        Error message displayed when the chosen file couldn't be read into an xarray. Simply a copy of the exception
        thrown during file reading.
        '''

        error_dialog = QErrorMessage()
        error_dialog.showMessage(error_msg)
        error_dialog.exec_()
示例#27
0
    def showDiagram(self, fig):
        if count_code != 0:
            DialogSecondIns = EpurDialogWindow(self, fig)
            DialogSecondIns.show()
            DialogSecondIns.exec()

        else:
            error_dialog = QErrorMessage()
            error_dialog.showMessage('Сначала рассчитайте конструкцию!')
            error_dialog.exec_()
 def open_pca_viewer(self):
     if (len(self.raman_datasets) > 0) and hasattr(self.active_dataset(),
                                                   'pca'):
         self.pca_viewer = pca_viewer(self.active_dataset())
         self.pca_viewer.show()
     else:
         error_message = QErrorMessage()
         error_message.showMessage('No PCA data available to visualize! '
                                   'Perform PCA first.')
         error_message.exec_()
示例#29
0
 def DrawGr(self):
     if count_code != 0:
         self.get_i_rod()
         print("Fig rod")
         fig_Gr = self.newCount.makeGraf(self.i_rod)
         print("Grafishere")
         self.showGraf(fig_Gr)
     else:
         error_dialog = QErrorMessage()
         error_dialog.showMessage('Сначала рассчитайте конструкцию!')
         error_dialog.exec_()
示例#30
0
    def excluirPedido(self, pedido):
        try:
            services.excluirPedidoItem(pedido)
            self.update_model_tableview()

        except (ValidationError, DBPedidosException) as error:
            error_dialog = QErrorMessage()
            error_dialog.setWindowTitle(error.errors)
            error_dialog.setWindowIcon(QIcon(main_icon))
            error_dialog.showMessage(error.message)
            error_dialog.exec_()
 def setPropertyForAllObjects(self):
     selectedPropertyIndices = self.selectedColumns() if self.model().isRowObjects else self.selectedRows()
     if len(selectedPropertyIndices) != 1:
         errorDialog = QErrorMessage(self)
         rowOrColumn = "column" if self.model().isRowObjects else "row"
         errorDialog.showMessage("Must select a single property " + rowOrColumn + ".")
         errorDialog.exec_()
         return
     try:
         propertyIndex = selectedPropertyIndices[0]
         dtype = self.model().propertyType(propertyIndex)
         if dtype is None:
             return
         obj = self.model().objects[0]
         prop = self.model().properties[propertyIndex]
         if "Write" not in prop.get('mode', "Read/Write"):
             return
         model = ObjectListTableModelQt([obj], [prop], self.model().isRowObjects, False)
         view = ObjectListTableViewQt(model)
         dialog = QDialog(self)
         buttons = QDialogButtonBox(QDialogButtonBox.Ok)
         buttons.accepted.connect(dialog.accept)
         buttons.rejected.connect(dialog.reject)
         vbox = QVBoxLayout(dialog)
         vbox.addWidget(view)
         vbox.addWidget(buttons)
         dialog.setWindowModality(Qt.WindowModal)
         dialog.exec_()
         for objectIndex, obj in enumerate(self.model().objects):
             row = objectIndex if self.model().isRowObjects else propertyIndex
             col = propertyIndex if self.model().isRowObjects else objectIndex
             index = self.model().index(row, col)
             if objectIndex == 0:
                 value = self.model().data(index)
             else:
                 if prop.get('action', '') == "fileDialog":
                     try:
                         getAttrRecursive(obj, prop['attr'])(value)
                         self.model().dataChanged.emit(index, index)  # Tell model to update cell display.
                     except:
                         self.model().setData(index, value)
                         self.model().dataChanged.emit(index, index)  # Tell model to update cell display.
                 else:
                     self.model().setData(index, value)
                     self.model().dataChanged.emit(index, index)  # Tell model to update cell display.
     except:
         pass