用 Python 刻 GUI 的 guietta

Hacker News Daily 翻到的奇怪工具 guietta,可以在 Python 下用奇怪的方法刻 GUI,範例就很好解釋了調性:

from guietta import _, Gui, Quit

gui = Gui(
    
  [  'Enter numbers:', '__a__'  , '+' , '__b__',  ['Calculate'] ],
  [  'Result:  -->'  , 'result' ,  _  ,    _   ,       _        ],
  [  _               ,    _     ,  _  ,    _   ,      Quit      ]
)

with gui.Calculate:
    gui.result = float(gui.a) + float(gui.b)
    
gui.run()

然後 Ubuntu 下的輸出會是:

Hacker News 的討論串「Guietta – Python module to create simple GUIs (github.com)」這邊有人也介紹了其他 Python 下刻 GUI 的方式,翻了一下也還不少有趣的東西。

guietta 看起來拿來刻一些簡單的東西應該還算堪用,尤其是討論裡面有提到在教學授課時可以簡化不少 interface 的問題。

Leave a Reply

Your email address will not be published. Required fields are marked *