Seregon/PkgToolBox

Toolbox for analyzing and editing pkg application files for psp,ps3, ps4 and ps5, includes the most useful functions you might need.

Python/57.3 KB/No license
tools/file_viewer_dialog.py
PkgToolBox / tools / file_viewer_dialog.py
1from PyQt5.QtWidgets import QDialog, QVBoxLayout, QTextEdit
2 
3class FileViewerDialog(QDialog):
4 def __init__(self, data, file_name, mode="text", parent=None):
5 super().__init__(parent)
6 self.setWindowTitle(f"View {file_name}")
7 layout = QVBoxLayout(self)
8
9 text_edit = QTextEdit()
10 if mode == "hex":
11 text_edit.setPlainText(' '.join(f'{b:02X}' for b in data))
12 else:
13 text_edit.setPlainText(data.decode('utf-8', errors='replace'))
14
15 text_edit.setReadOnly(True)
16 layout.addWidget(text_edit)
17 self.resize(600, 400)
18