def paste_matrix_from_clipboard()

in src/open_vp_cal/widgets/project_settings_widget.py [0:0]


    def paste_matrix_from_clipboard(self):
        """ Pastes the matrix from the clipboard into the spin boxes

        """
        value = QApplication.clipboard().text()
        if not value:
            QMessageBox.warning(self, "Empty Clipboard", "The clipboard is empty")
            return
        mode = self.copy_format_combo.currentText()
        if mode == constants.CopyFormats.PYTHON:
            try:
                python_values = json.loads(value)
                if len(python_values) != 3 and len(python_values) != 9:
                    QMessageBox.warning(self,
                                        "Invalid Format",
                                        "Copied Text should be a nested 3x3 list or a single list of 9 values")
                    return
                if len(python_values) == 3:
                    for i in range(3):
                        for j in range(3):
                            self.matrix_widgets[i][j].setValue(python_values[i][j])
                else:
                    for i in range(3):
                        for j in range(3):
                            self.matrix_widgets[i][j].setValue(python_values[i * 3 + j])
            except json.JSONDecodeError:
                QMessageBox.warning(self, "Invalid Format", "The copied text is not in a valid format")
                return

        elif mode == constants.CopyFormats.CSV:
            csv_values = value.split(",")
            if len(csv_values) != 9:
                QMessageBox.warning(self, "Invalid Format", "The copied text is not in a valid format")
                return
            for i in range(3):
                for j in range(3):
                    self.matrix_widgets[i][j].setValue(float(csv_values[i * 3 + j]))