主要代码如下:

# author https://yunp.top


import webview


class JSAPI:
    def sayHello(self, name: str):
        return f'Hello {name}'


if __name__ == '__main__':
    jsapi = JSAPI()
    webview.create_window('调用 Python', 'www/index.html', js_api=jsapi, width=600, height=400)
    webview.start()