diff --git a/file.py b/file.py index b7f9f27..31c6594 100644 --- a/file.py +++ b/file.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -from PyQt6.QtWidgets import QWidget, QLabel, QFileDialog +from PyQt6.QtWidgets import QWidget, QPlainTextEdit, QFileDialog, QVBoxLayout class FileActions: @@ -26,7 +26,7 @@ class File: self.path = path self.name = name - file = open(path, "r") + file = open(path, "rb") file_content = file.read() file.close() @@ -34,8 +34,13 @@ class File: # the widget that contains all the file content self.content_widget = QWidget(self.app.main_window.openFileTabs) - self.content_label = QLabel(self.content_widget) # the label for the text in the file - self.content_label.setText(file_content) + self.content_widget_layout = QVBoxLayout() + + self.content_binary_input = QPlainTextEdit(self.content_widget) + self.content_widget_layout.addWidget(self.content_binary_input) + self.content_binary_input.setPlainText(self.app.utils.bstring_to_oz(file_content)) + + self.content_widget.setLayout(self.content_widget_layout) self.app.main_window.openFileTabs.addTab( # add a tab for the file in the top files list self.content_widget, diff --git a/utils.py b/utils.py index ee7ea9b..2ce17a7 100644 --- a/utils.py +++ b/utils.py @@ -10,3 +10,8 @@ class Utils: self.app = app self.home_path = str(Path.home()) + + def bstring_to_oz(self, data): # convert binary data to a string of ones and zeros (oz) + oz_string = " ".join([format(byte, "08b") for byte in data]) + + return oz_string