V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
hxse
V2EX  ›  Python

Flet, 用 Python 写 flutter, 一个 electron 的代替品

  •  
  •   hxse · 2022-07-17 15:48:24 +08:00 · 2389 次点击
    这是一个创建于 620 天前的主题,其中的信息可能已经有所发展或是发生改变。

    https://github.com/flet-dev/flet

    import flet
    from flet import IconButton, Page, Row, TextField, icons
    
    def main(page: Page):
        page.title = "Flet counter example"
        page.vertical_alignment = "center"
    
        txt_number = TextField(value="0", text_align="right", width=100)
    
        def minus_click(e):
            txt_number.value = int(txt_number.value) - 1
            page.update()
    
        def plus_click(e):
            txt_number.value = int(txt_number.value) + 1
            page.update()
    
        page.add(
            Row(
                [
                    IconButton(icons.REMOVE, on_click=minus_click),
                    txt_number,
                    IconButton(icons.ADD, on_click=plus_click),
                ],
                alignment="center",
            )
        )
    
    flet.app(target=main)
    

    试例 大家觉得怎么样

    ChrisFreeMan
        1
    ChrisFreeMan  
       2022-07-17 18:24:40 +08:00 via iPhone
    听起来很梦幻,但是我之前被 python Gui 开发坑怕了。
    catsoul
        2
    catsoul  
       2022-07-18 09:02:54 +08:00
    可以,不过打算再观望一下,毕竟这种类型的东东层出不穷但是真正维护到具有实用价值的寥寥
    lolizeppelin
        3
    lolizeppelin  
       2022-07-19 14:50:52 +08:00
    flutter 学习麻烦在于熟悉 flutter 本身的控件,用 python 来写控件还不是得熟悉 flutter 的控件?
    就好比用 python 来写 Spring Boot,你要熟悉的是 Spring Boot 而不光是 java 。

    dart 的语法又不多,dart 本身也不难,还是原生协程,转用 python 写毫无意义。
    mayli
        4
    mayli  
       2022-07-26 02:35:32 +08:00
    @lolizeppelin 确实,混合语言都有调用问题,写来写去如果不是语法上完美支持,都会遇到所谓的坑。不过 py->flutter->web 挺梦幻的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3356 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 13:38 · PVG 21:38 · LAX 06:38 · JFK 09:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.