Spaces:
Sleeping
Sleeping
File size: 1,032 Bytes
fe0c99f 447dcc5 fe0c99f de8ccff fe0c99f 447dcc5 fe0c99f 2d887df 447dcc5 de8ccff fe0c99f 2d887df fe0c99f 447dcc5 fe0c99f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #!/usr/bin/env python3
import sys
import webview
from api.bridge import CalculusAPI
from config import UI_DIR
# Track if window is already created (prevents double-launch on macOS)
_window_created = False
def launch(api: CalculusAPI) -> None:
"""Create and start the pywebview window. Single source of truth for window config."""
global _window_created
# Prevent double window creation on macOS multiprocessing spawn
if _window_created:
return
_window_created = True
ui_path = str(UI_DIR / "index.html")
webview.create_window(
title="Calculus Animator",
url=ui_path,
js_api=api,
width=1440,
height=920,
resizable=True,
min_size=(1024, 700),
)
webview.start(debug=False)
def main():
launch(CalculusAPI())
if __name__ == "__main__":
# Required for multiprocessing on macOS/Windows
if sys.platform in ('darwin', 'win32'):
import multiprocessing
multiprocessing.freeze_support()
main()
|