Skip to content

How to achieve conditional rendering of user control children #766

Answered by Francois-Belanger
devtud asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, you have to work by reference to do this simply.

class MyControl(ft.UserControl):
    def __init__(self):
        self.dynamic_member = 0
        self.text_box = ft.Text("oops, it's 0")

    def some_callback(self):
        self.dynamic_member += 1
        self.text_box .value = f"it's {self.dynamic_member}"
        self.update()

    def build(self):
        return self.text_box

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by devtud
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants