From d86c9acc58c06f173404135139083e174bbd5586 Mon Sep 17 00:00:00 2001 From: EKNr1 Date: Mon, 18 Nov 2024 18:00:35 +0100 Subject: [PATCH] So now, it can actually read files. --- main.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index abcc6dd..9068796 100644 --- a/main.py +++ b/main.py @@ -22,10 +22,22 @@ class BreadEditor: connect_gui(self) def open_file(self, file_path): - self.open_files[file_path] = file_path.split("/")[-1] # set name that shows in the tab list + file = open(file_path, "r") + file_content = file.read() + file.close() + + self.open_files[file_path] = { + "name": file_path.split("/")[-1], # set name that shows in the tab list + "content": file_content + } + + content_widget = QtWidgets.QWidget(self.main_window.openFileTabs) + content_label = QtWidgets.QLabel(content_widget) + content_label.setText(file_content) + self.main_window.openFileTabs.addTab( - QtWidgets.QWidget(self.main_window.openFileTabs), - self.open_files[file_path] + content_widget, + self.open_files[file_path]["name"] ) def run(self):