FlexxPython 的 GUI 開發(fā)工具
Flexx 是一個純 Python 工具包,用來創(chuàng)建圖形化界面應(yīng)用程序。其使用 Web 技術(shù)進行界面的渲染。你可以用 Flexx 來創(chuàng)建桌面應(yīng)用,同時也可以導(dǎo)出一個應(yīng)用到獨立的 HTML 文檔。因為使用純 Python 開發(fā),所以 Flexx 是跨平臺的。只需要有 Python 和瀏覽器就可以運行。如果是使用桌面模式運行,推薦使用 Firefox 。
Flexx 使用模塊化設(shè)計,包含一些子系統(tǒng):
-
ui - UI 部件
-
app - 事件循環(huán)和服務(wù)器
-
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()評論
圖片
表情
