Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增响应式控件 #12

Closed
miswanting opened this issue Apr 29, 2020 · 1 comment
Closed

新增响应式控件 #12

miswanting opened this issue Apr 29, 2020 · 1 comment
Assignees

Comments

@miswanting
Copy link
Owner

现在的控件生成方式是生成式,若要接受用户变量,需要这样编写:

value = None
def callback(data):
    nonlocal value
    value=data
def submit():
    nonlocal value
    print(value)
a.input(callback)
a.b('确认', submit)

这样不会太麻烦了一点吗?

通过引入响应式控件,同样的操作可以用这样的代码实现:

el = a.input()
def submit():
    nonlocal el
    print(el['data'])
a.b('确认', submit)

更进一步,如果我们需要在生成input控件3秒后更改用户看到的input界面的内容,还可以这样:

el = a.input()
time.sleep(3)
el.set({'text': 'new value'})

如何呢?

@miswanting
Copy link
Owner Author

计划暂停并合并至 #20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant