diff --git a/.gitignore b/.gitignore index 9d03479..5ff788c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,7 @@ build/ dist/ .pytest_cache/ .vscode/* +!.vscode/launch.json +!.vscode/tasks.json !.vscode/tasks.json .ruff_cache/ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..8782940 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python Debugger: Module", + "type": "debugpy", + "request": "launch", + "module": "bedit_gui", + "preLaunchTask": "Qt: Generate files", + "cwd": "${workspaceFolder}", + "env": { + "QT_QPA_PLATFORMTHEME": "qt6ct", + "QT_QPA_PLATFORM": "xcb" + } + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 5ab06bd..b0c7914 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -25,6 +25,48 @@ "panel": "dedicated" }, "problemMatcher": [] + }, + { + "label": "Qt: Open Designer", + "type": "shell", + "command": "${workspaceFolder}/.venv/bin/pyside6-designer", + "args": [], + "options": { + "cwd": "${workspaceFolder}", + "env": { + "QT_QPA_PLATFORMTHEME": "qt6ct", + "QT_QPA_PLATFORM": "xcb" + } + }, + "problemMatcher": [], + "presentation": { + "reveal": "always", + "panel": "dedicated" + } + }, + { + "label": "Qt: Generate files", + "type": "process", + "command": "${workspaceFolder}/.venv/bin/python", + "args": [ + "${workspaceFolder}/scripts/generate_qt_files.py" + ], + "options": { + "cwd": "${workspaceFolder}", + "env": { + "PATH": "${workspaceFolder}/.venv/bin:${env:PATH}" + } + }, + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "clear": true, + "reveal": "always", + "panel": "dedicated" + }, + "problemMatcher": [] } ] -} +} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 94c8282..29e7b47 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ dependencies = [ [project.scripts] bedit-graphviz = "bedit_util.graphviz:main" bedit-simulate = "bedit_util.simulate:main" +bedit = "bedit_gui.application:main" [project.optional-dependencies] dev = [ diff --git a/scripts/generate_qt_files.py b/scripts/generate_qt_files.py new file mode 100644 index 0000000..63aa1a3 --- /dev/null +++ b/scripts/generate_qt_files.py @@ -0,0 +1,62 @@ + +from __future__ import annotations + +import subprocess +from pathlib import Path + + +ROOT = Path(__file__).resolve().parents[1] +GUI_PACKAGE = ROOT / "src" / "bedit_gui" + +FORMS_DIR = GUI_PACKAGE / "ui" / "forms" +GENERATED_UI_DIR = GUI_PACKAGE / "ui" / "generated" + +QRC_FILE = GUI_PACKAGE / "resources" / "resources.qrc" +GENERATED_RESOURCES = ( + GUI_PACKAGE + / "resources" + / "generated" + / "resources_rc.py" +) + + +def execute(*command: str) -> None: + print("+", " ".join(command)) + subprocess.run(command, check=True) + + +def generate_ui() -> None: + GENERATED_UI_DIR.mkdir(parents=True, exist_ok=True) + + for source in sorted(FORMS_DIR.glob("*.ui")): + destination = GENERATED_UI_DIR / f"ui_{source.stem}.py" + + execute( + "pyside6-uic", + str(source), + "-o", + str(destination), + ) + + +def generate_resources() -> None: + GENERATED_RESOURCES.parent.mkdir( + parents=True, + exist_ok=True, + ) + + execute( + "pyside6-rcc", + str(QRC_FILE), + "-o", + str(GENERATED_RESOURCES), + ) + + +def main() -> None: + generate_ui() + generate_resources() + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/src/bedit_gui/__init__.py b/src/bedit_gui/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bedit_gui/__main__.py b/src/bedit_gui/__main__.py index 58367d9..95be004 100644 --- a/src/bedit_gui/__main__.py +++ b/src/bedit_gui/__main__.py @@ -1,5 +1,3 @@ -def main(): - pass +from bedit_gui.application import main -if __name__ == "__name__": - raise SystemExit(main()) \ No newline at end of file +raise SystemExit(main()) \ No newline at end of file diff --git a/src/bedit_gui/application.py b/src/bedit_gui/application.py new file mode 100644 index 0000000..7a58e8a --- /dev/null +++ b/src/bedit_gui/application.py @@ -0,0 +1,18 @@ +from __future__ import annotations +import sys + +from PySide6.QtWidgets import QApplication + +from bedit_gui.resources.generated import resources_rc +from bedit_gui.views.main_window import MainWindow + +def main() -> int: + app = QApplication(sys.argv) + + app.setOrganizationName("BEdit") + app.setApplicationName("BEdit") + + window = MainWindow() + window.show() + + return app.exec() \ No newline at end of file diff --git a/src/bedit_gui/commands/__init__.py b/src/bedit_gui/commands/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bedit_gui/controllers/__init__.py b/src/bedit_gui/controllers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bedit_gui/documents/__init__.py b/src/bedit_gui/documents/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bedit_gui/resources/generated/.gitignore b/src/bedit_gui/resources/generated/.gitignore new file mode 100644 index 0000000..708428b --- /dev/null +++ b/src/bedit_gui/resources/generated/.gitignore @@ -0,0 +1,3 @@ +* +!__init__.py +!.gitignore \ No newline at end of file diff --git a/src/bedit_gui/resources/generated/__init__.py b/src/bedit_gui/resources/generated/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bedit_gui/services/__init__.py b/src/bedit_gui/services/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bedit_gui/ui/forms/main_window.ui b/src/bedit_gui/ui/forms/main_window.ui new file mode 100644 index 0000000..cd4835e --- /dev/null +++ b/src/bedit_gui/ui/forms/main_window.ui @@ -0,0 +1,31 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + 0 + 0 + 800 + 22 + + + + + + + + diff --git a/src/bedit_gui/ui/generated/.gitignore b/src/bedit_gui/ui/generated/.gitignore new file mode 100644 index 0000000..708428b --- /dev/null +++ b/src/bedit_gui/ui/generated/.gitignore @@ -0,0 +1,3 @@ +* +!__init__.py +!.gitignore \ No newline at end of file diff --git a/src/bedit_gui/ui/generated/__init__.py b/src/bedit_gui/ui/generated/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bedit_gui/utils/__init__.py b/src/bedit_gui/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bedit_gui/views/__init__.py b/src/bedit_gui/views/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bedit_gui/views/dialogs/__init__.py b/src/bedit_gui/views/dialogs/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bedit_gui/views/docks/__init__.py b/src/bedit_gui/views/docks/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bedit_gui/views/editor/__init__.py b/src/bedit_gui/views/editor/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bedit_gui/views/main_window.py b/src/bedit_gui/views/main_window.py new file mode 100644 index 0000000..8da233e --- /dev/null +++ b/src/bedit_gui/views/main_window.py @@ -0,0 +1,11 @@ +from PySide6.QtWidgets import QMainWindow + +from bedit_gui.ui.generated.ui_main_window import Ui_MainWindow + + +class MainWindow(QMainWindow): + def __init__(self) -> None: + super().__init__() + + self.ui = Ui_MainWindow() + self.ui.setupUi(self) \ No newline at end of file