From 8f8c11772eb401ca3e0384528fd04308edd74bd6 Mon Sep 17 00:00:00 2001 From: EKNr1 Date: Mon, 18 Nov 2024 17:20:49 +0100 Subject: [PATCH] File opening is now really working. (Shows a tab menu with the opened files.) --- gui/raw_ui/main_window.ui | 20 +++++++++++++++----- main.py | 9 ++++++++- requirements.txt | 1 + utils.py | 3 ++- 4 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 requirements.txt diff --git a/gui/raw_ui/main_window.ui b/gui/raw_ui/main_window.ui index 67a0bc0..a765abd 100644 --- a/gui/raw_ui/main_window.ui +++ b/gui/raw_ui/main_window.ui @@ -6,20 +6,30 @@ 0 0 - 800 - 600 + 861 + 548 - MainWindow + Bread Editor - + + + + + + -1 + + + + + 0 0 - 800 + 861 20 diff --git a/main.py b/main.py index 3215218..abcc6dd 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,7 @@ from connect_gui import connect_gui class BreadEditor: def __init__(self): self.utils = Utils(self) - self.open_files = [] + self.open_files = {} self.qt_app = QtWidgets.QApplication(sys.argv) @@ -21,6 +21,13 @@ 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 + self.main_window.openFileTabs.addTab( + QtWidgets.QWidget(self.main_window.openFileTabs), + self.open_files[file_path] + ) + def run(self): self.QTMainWindow.show() sys.exit(self.qt_app.exec()) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..31d9bef --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +PyQt6>=6.4.2 \ No newline at end of file diff --git a/utils.py b/utils.py index 959716d..fe46e30 100644 --- a/utils.py +++ b/utils.py @@ -18,4 +18,5 @@ class Utils: dialog.setViewMode(QFileDialog.ViewMode.List) if dialog.exec(): - self.app.open_files += dialog.selectedFiles() + for file_path in dialog.selectedFiles(): + self.app.open_file(file_path)