commit 2797c3ca4444bea405cec0fa3484503b7b0189b0 Author: EKNr1 Date: Sun Nov 17 18:54:51 2024 +0100 File opening working. (Only the popup that sets the variable.) diff --git a/connect_gui.py b/connect_gui.py new file mode 100644 index 0000000..f21b89e --- /dev/null +++ b/connect_gui.py @@ -0,0 +1,4 @@ +#!/usr/bin/python3 + +def connect_gui(app): + app.main_window.openFile.triggered.connect(app.utils.open_file) diff --git a/gui/raw_ui/main_window.ui b/gui/raw_ui/main_window.ui new file mode 100644 index 0000000..67a0bc0 --- /dev/null +++ b/gui/raw_ui/main_window.ui @@ -0,0 +1,55 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + 0 + 0 + 800 + 20 + + + + + File + + + + + + + + + false + + + false + + + Open + + + Ctrl+O + + + true + + + + + + diff --git a/gui/raw_ui/ui_to_py.py b/gui/raw_ui/ui_to_py.py new file mode 100644 index 0000000..e666ff6 --- /dev/null +++ b/gui/raw_ui/ui_to_py.py @@ -0,0 +1,18 @@ +#!/usr/bin/python3 + +import os + +input_debug = input("Do you want to debug the gui scripts? (Make gui scripts executable.) (y/n): ") + +debug = input_debug == "y" + +params = "-o" +if debug: + params = "-xo" + +paths = { + "main_window.ui": "main_window.py" +} + +for ui_file, script_out in paths.items(): + os.system(f"pyuic6 {ui_file} {params} ../{script_out}") diff --git a/main.py b/main.py new file mode 100644 index 0000000..3215218 --- /dev/null +++ b/main.py @@ -0,0 +1,31 @@ +#!/usr/bin/python3 + +import sys +from PyQt6 import QtWidgets +from gui.main_window import Ui_MainWindow +from utils import Utils +from connect_gui import connect_gui + + +class BreadEditor: + def __init__(self): + self.utils = Utils(self) + self.open_files = [] + + self.qt_app = QtWidgets.QApplication(sys.argv) + + self.QTMainWindow = QtWidgets.QMainWindow() + + self.main_window = Ui_MainWindow() + self.main_window.setupUi(self.QTMainWindow) + + connect_gui(self) + + def run(self): + self.QTMainWindow.show() + sys.exit(self.qt_app.exec()) + + +if __name__ == "__main__": + editor = BreadEditor() + editor.run() diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..959716d --- /dev/null +++ b/utils.py @@ -0,0 +1,21 @@ +#!/usr/bin/python3 + +from pathlib import Path +from PyQt6.QtWidgets import QFileDialog + + +class Utils: + def __init__(self, app): + self.app = app + + self.home_path = str(Path.home()) + + def open_file(self): + dialog = QFileDialog(self.app.QTMainWindow) + dialog.setDirectory(self.home_path) + dialog.setFileMode(QFileDialog.FileMode.ExistingFiles) + dialog.setNameFilters(["Binary (*.bin)", "Any (*)"]) + dialog.setViewMode(QFileDialog.ViewMode.List) + + if dialog.exec(): + self.app.open_files += dialog.selectedFiles()