python小工具: GUI開發工具 Flexx

前言
flexx是一個純python工具包,用於創建圖形界面應用程序。它使用Web技術呈現接口。您可以使用flexx創建桌面應用程序,也可以導出應用程序以分離HTML文檔。FlexX是跨平臺的,因爲它使用純Python開發。它只需要運行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()

相信大家很少會用到這個庫吧?今天爲大家介紹這款flexx庫,建議大家收藏,因爲隨着深入學習Python,總會與flexx相遇到滴。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章