-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.py
31 lines (27 loc) · 880 Bytes
/
debug.py
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
from json import JSONEncoder
from multiprocessing import freeze_support
from typing import Any
import webview
from backend import API
if __name__ == "__main__":
# Monkey patch JSONEncoder to handle dataclasses
def _default(self: JSONEncoder, obj: Any): # pyright: ignore[]
return getattr(obj.__class__, "to_dict", _default.default)(obj) # pyright: ignore[]
_default.default = JSONEncoder().default # pyright: ignore[]
JSONEncoder.default = _default # pyright: ignore[]
freeze_support()
api = API()
window = webview.create_window(
"Texa",
"http://localhost:3000",
js_api=api,
width=850,
height=700,
min_size=(600, 500),
easy_drag=False,
frameless=True,
)
window.events.closing += api.on_closing
api.bind_window(window)
webview.start(debug=True)
exit(0)