Strange behavior of Ref
s
#506
-
Refs have a strange behavior. I dont know if this is a bug or its normal/intentional.. from flet import *
def main(page: Page):
page.title = "Ref Misbehavior"
page.window_height = 200
page.window_width = 400
def click(e):
# TextField has no property text, but FilledButton.text is successfully updated
fake_ref.current.text = "Hello France"
page.update()
fake_ref = Ref[TextField]() # changing from Ref[TextField] to Ref[Text] still works
page.add(
FilledButton(
"Hello Estonia",
fake_ref,
on_click=click
)
)
flet.app(target=main,) Can someone please explain why this works as such?? using |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
TextField doesn't have "text" properly, but it has "value". |
Beta Was this translation helpful? Give feedback.
-
Because in Python |
Beta Was this translation helpful? Give feedback.
Because in Python
Ref[Textfield]
is a generic of typeTextfield
. It's a type "hint". Python does not enforce types - you can do whatever you like.