diff --git a/Home.md b/Home.md index 49af442..f8791bf 100644 --- a/Home.md +++ b/Home.md @@ -4,3 +4,29 @@ apt install python3-webengine-gtk3 ``` +## 使用 + +```python + +import gi, os +gi.require_version('Gtk', '3.0') + +from gi.repository import Gtk +from webengine.gtk3 import WebEngine, create_setting, create_hmr_server + +__dir__ = os.path.dirname(os.path.realpath(__file__)) +web_root = os.path.join(__dir__, './webapp') + +win = Gtk.window() +web = WebEngine() +hmr = create_hmr_server() + +web.set_root(web_root) + +web.use(hmr).load() +# 默认会加载 '/index.html, 上面的写法等价于 web.use(hmr).load('/index.html') + +win.add(web) +Gtk.main() + +``` \ No newline at end of file