import sys
import os
from pathlib import Path
import traceback

CURDIR = Path(__file__).parent
TCL_BASE = CURDIR / "site-packages" / "tcl"

# --- Point Tcl/Tk to the correct location ---
os.environ["TCL_LIBRARY"] = str(TCL_BASE / "tcl8.6")
os.environ["TK_LIBRARY"] = str(TCL_BASE / "tk8.6")

def main():
	# pylint: disable=wrong-import-position
	from jimlet.app import JimletApp

	app = JimletApp(title="Jimlet TTS Converter")
	app.run(start_mainloop=True)

try:
    main()
except Exception:
    (CURDIR / "CRASH.txt").write_text(
        traceback.format_exc()
    )
