-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathipc.py
More file actions
36 lines (27 loc) · 763 Bytes
/
ipc.py
File metadata and controls
36 lines (27 loc) · 763 Bytes
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
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "justbe-webview",
# ]
#
# [tool.uv.sources]
# justbe-webview = { path = "../" }
# ///
import asyncio
from justbe_webview import WebView, Options, ContentHtml, IpcNotification
async def main():
print("Creating webview")
config = Options(
title="Simple",
load=ContentHtml(
html='<button onclick="window.ipc.postMessage(`button clicked ${Date.now()}`)">Click me</button>'
),
ipc=True,
)
async with WebView(config) as webview:
async def handle_ipc(event: IpcNotification):
print(event.message)
webview.on("ipc", handle_ipc)
print("Webview closed")
if __name__ == "__main__":
asyncio.run(main())