79629267

Date: 2025-05-19 18:18:19
Score: 1
Natty:
Report link

I found a way to get the result I wanted - but it seems a little bit like a hack to me. What do you think?

Since all controls (=widgets) are stored in a list, you can delete and add items from that list at any position/index of the list.

I did it the following way:

def reset(e):
    # remove the Dropdown completly from the GUI
    page.remove_at(0) # 0 is the index of the control in the list

    # add the Dropdown again at the same position
    dropdown = ft.Dropdown(
        label = 'Examples',
        expand = True,
        options = [
            ft.DropdownOption(text='Option 1'),
            ft.DropdownOption(text='Option 2'),
            ft.DropdownOption(text='Option 3'),
        ]
    )
    page.insert(0, dropdown)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Alex