Data is now represented in readable Binary.
This commit is contained in:
parent
7063c7d152
commit
64bb1fbf15
2 changed files with 14 additions and 4 deletions
13
file.py
13
file.py
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
from PyQt6.QtWidgets import QWidget, QLabel, QFileDialog
|
from PyQt6.QtWidgets import QWidget, QPlainTextEdit, QFileDialog, QVBoxLayout
|
||||||
|
|
||||||
|
|
||||||
class FileActions:
|
class FileActions:
|
||||||
|
@ -26,7 +26,7 @@ class File:
|
||||||
self.path = path
|
self.path = path
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
file = open(path, "r")
|
file = open(path, "rb")
|
||||||
file_content = file.read()
|
file_content = file.read()
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
|
@ -34,8 +34,13 @@ class File:
|
||||||
|
|
||||||
# the widget that contains all the file content
|
# the widget that contains all the file content
|
||||||
self.content_widget = QWidget(self.app.main_window.openFileTabs)
|
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_widget_layout = QVBoxLayout()
|
||||||
self.content_label.setText(file_content)
|
|
||||||
|
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.app.main_window.openFileTabs.addTab( # add a tab for the file in the top files list
|
||||||
self.content_widget,
|
self.content_widget,
|
||||||
|
|
5
utils.py
5
utils.py
|
@ -10,3 +10,8 @@ class Utils:
|
||||||
self.app = app
|
self.app = app
|
||||||
|
|
||||||
self.home_path = str(Path.home())
|
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
|
||||||
|
|
Loading…
Reference in a new issue