基于Web技術的Python UI 工具箱:Flexx
Flexx 是一個純 Python 工具包,用來創建圖形化界面應用程序。其使用 Web 技術進行界面的渲染。你可以用 Flexx 來創建桌面應用和Web應用,同時也可以導出一個應用到獨立的 HTML 文檔。因為使用純 Python 開發,所以 Flexx 是跨平臺的。只需要有 Python 和瀏覽器就可以運行。如果是使用桌面模式運行,推薦使用 Firefox 。
Flexx 使用模塊化設計,包含一些子系統:
-
ui - UI 部件
-
app - 事件循環和服務器
-
react - reactive 編程
-
pyscript - Python to JavaScript transpiler
-
webruntime - to launch a runtime
示例代碼:
from flexx import app, ui, react
class Example(ui.Widget):
def init(self):
self.count = 0
with ui.HBox():
self.button = ui.Button(text='Click me', flex=0)
self.label = ui.Label(flex=1)
@react.connect('button.mouse_down')
def _handle_click(self, down):
if down:
self.count += 1
self.label.text('clicked %i times' % self.count)
main = app.launch(Example)
app.run() Current status
Flexx is still very much a work in progress. Please don't go use it just yet for anything serious. The public API can change without notice. However, we're interested in feedback, so we invite you to play with it!
Getting started
- clone the repo
- put the repo dir in your PYTHONPATH
- python setup.py install
- run the examples
Demo server
There is an Amazon instance running some demos on http://52.21.93.28:8000/ (unless I turned it off for testing, etc.).
本文由用戶 ggect 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!