更新 Home
parent
480db94307
commit
bd18d758f0
26
Home.md
26
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()
|
||||
|
||||
```
|
Loading…
Reference in New Issue