Skip to content
Snippets Groups Projects
Commit eff85a17 authored by Stefan Palkovits's avatar Stefan Palkovits
Browse files

working json editor

parent d1c55939
Branches edit_json
No related tags found
No related merge requests found
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton, QLineEdit, QLabel, QFileDialog, QMessageBox, QGridLayout, QDialog, QInputDialog
import json
import os
def edit_tab():
tab = QWidget()
......@@ -91,7 +92,7 @@ def edit_tab():
row = 0
for nested_key, nested_value in value.items():
nested_label = QLabel(nested_key)
nested_line_edit = QLineEdit(', '.join(nested_value) if isinstance(nested_value, list) else str(nested_value))
nested_line_edit = QLineEdit(', '.join([os.path.basename(v) for v in nested_value]) if isinstance(nested_value, list) else str(nested_value))
add_file_button = QPushButton("Add File")
add_file_button.clicked.connect(lambda _, k=nested_key, v=nested_value: add_file_to_list(k, v, nested_json_fields))
nested_grid_layout.addWidget(nested_label, row, 0)
......@@ -120,7 +121,7 @@ def edit_tab():
if not isinstance(nested_value, list):
nested_value = []
nested_value.extend(file_names)
nested_json_fields[nested_key].setText(', '.join(nested_value))
nested_json_fields[nested_key].setText(', '.join([os.path.basename(f) for f in nested_value]))
def save_nested_json(dialog, key, nested_json_fields):
nested_data = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment