-
Notifications
You must be signed in to change notification settings - Fork 1
Project Structure
Astro Python is split into two sub-projects: astro-app and python-app.
Astro App is a static website built using Astro, with Tailwind CSS, and Vue Components.
Python App is a Simple Python Application template that uses WebUI to serve the Astro App in a webview window using the users currently installed web browser (firefox or chromium based).
WebUI allows for interop between python and javascript, and this project projives a simple event based IPC mechanism to allow the Astro App to communicate with the Python App and vice versa.
The root of the project contains the following files and directories:
-
package.json- Mono-repo package.json. -
pyproject.toml- Python project configuration. -
poetry.toml- Contains dependencies for the Python App and Configuration for Poetry. -
astro-python.spec- Contains the PyInstaller spec for the Project, this is used for packaging.
packages/astro-app is the root of the Astro App project. It contains the following files and directories:
-
src/- Contains the source code for the Astro App. -
public/- Contains the public assets for the Astro App. -
package.json- Contains the dependencies for the Astro App. -
astro.config.mjs- Contains the configuration for the Astro App. -
tailwind.config.js- Contains the configuration for the Tailwind CSS framework. -
tsconfig.json- Contains the configuration for the TypeScript compiler.
While you should look at the Astro documentation for more info about the astro directory structure, there are some important things to note in the src/ directory:
-
src/scripts/- Contains scripts used to handle the IPC between the Astro App and the Python App.ipc.tsis the main IPC script. -
src/plugins/- Contains plugins for the Astro App.-
vue/webui-bridge.tsinjects the IPC script into the Vue context for the Astro App.
-
-
Application.ts- Vue entry point for the Astro App, this is where the Vue App is created and IPC is injected. -
consts.ts- Contains constants used in the Astro App, Application Name, Description, Version. Etc.
packages/python-app is the root of the Python App project. It contains the following files and directories:
-
event_handlers/- Contains the event handlers for the Python App, these are simple async functions that are called when an event is emitted from the Astro App. -
lib- Contains the library code for the Python App.-
event_manager.py- Contains the event manager, probably overcomplicated global event handler running async handlers in a separate thread. -
window_manager.py- Contains the window manager, simple class to manage WebUI windows, and attach event handlers for the IPC mechanism.
-
-
tests- Contains the tests for the Python App, you should add tests for your event handlers here. -
main.py- Contains the main entry point for the Python App, this is where the WebUI window is created and the event manager is started. -
pyinstaller_hooks.py- Contains the hooks for PyInstaller, this is used to monkey patch how webui loads the libraries in the packaged application.