caught an error when applying the yaml code and displey it in a debug dialog

master
Jaka Perovšek 2024-10-05 12:17:48 +02:00
parent 3036478f1d
commit 4814eacbad
2 changed files with 20 additions and 3 deletions

View File

@ -228,8 +228,13 @@ class CodeEditorWidget(QWidget):
self.status_label.setText(self.status_editor_code_changed) self.status_label.setText(self.status_editor_code_changed)
def apply_code(self): def apply_code(self):
tapes = yaml.safe_load(self.editor.toPlainText()) try:
self.parent.validation_widget.load_tapes(tapes) tapes = yaml.safe_load(self.editor.toPlainText())
self.parent.validation_widget.load_tapes(tapes)
except yaml.scanner.ScannerError as e:
dlg = DebugDialog(f"Error applying yaml code:\n\n{str(e)}")
dlg.exec()
class TapeEditWidget(QWidget): class TapeEditWidget(QWidget):
@ -513,6 +518,18 @@ class InstallWidget(QWidget):
download_ffmpeg(self.ffmpeg_dir.directory) download_ffmpeg(self.ffmpeg_dir.directory)
self.does_ffmpeg_exist() self.does_ffmpeg_exist()
class DebugDialog(QDialog):
def __init__(self, text):
super().__init__()
self.setWindowTitle("Error and debug info")
self.description = QPlainTextEdit(text)
self.description.setEnabled(False)
layout = QVBoxLayout(self)
layout.addWidget(self.description)
class MainWidget(QWidget): class MainWidget(QWidget):
def __init__(self): def __init__(self):

View File

@ -2,7 +2,7 @@ from PySide6.QtCore import QSize, Qt, Slot, QRect, QFileSystemWatcher, Signal, Q
from PySide6.QtGui import QIcon, QAction, QShortcut, QKeySequence, QPainter, QColor, QTextFormat, QPixmap, QFontMetrics from PySide6.QtGui import QIcon, QAction, QShortcut, QKeySequence, QPainter, QColor, QTextFormat, QPixmap, QFontMetrics
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QWidget, QLabel, QVBoxLayout, QHBoxLayout, \ from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QWidget, QLabel, QVBoxLayout, QHBoxLayout, \
QGroupBox, QLineEdit, QCheckBox, QSpinBox, QPlainTextEdit, QSizePolicy, QGridLayout, QTextEdit, QScrollArea, QFrame, \ QGroupBox, QLineEdit, QCheckBox, QSpinBox, QPlainTextEdit, QSizePolicy, QGridLayout, QTextEdit, QScrollArea, QFrame, \
QDoubleSpinBox, QFormLayout, QTimeEdit, QFileDialog QDoubleSpinBox, QFormLayout, QTimeEdit, QFileDialog, QDialog
import webbrowser import webbrowser
import validators import validators