Create 'bind' method for every ui object #3275
Closed
bin-san
started this conversation in
Ideas / Feature Requests
Replies: 2 comments 2 replies
-
Just same as import flet as ft
def main(page: ft.Page):
page.title = "Elevated button with 'click' event"
def button_clicked(e):
b.data['value'] += 1
t.value = f"Button clicked {b.data['value']} time(s)"
page.update()
b = ft.ElevatedButton("Button with 'click' event", on_click=button_clicked, data={'value':0})
t = ft.Text()
page.add(b, t)
ft.app(target=main) |
Beta Was this translation helpful? Give feedback.
1 reply
-
After looking into the source I found the way to achieve this: from nicegui import bind, BindableProperty
class X:
a = BindableProperty()
class Y:
b = BindableProperty()
x = X()
y = Y()
bind(x, 'a', y, 'b')
x.a = 10
print(y.b) # prints 10 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The ui object only binds it text or value to something. but will it not be more
reactive
if a generalised bind method is provided?I guess this will give user more freedom for making their app more reactive.
Beta Was this translation helpful? Give feedback.
All reactions