Skip to content

Dynamic ButtonGroup not updated #104

Description

@jo47011

Hi Michael,

I'm currently working on a RadioInterface(SupervisedClientInterface) which I can contribute once I have it running. I'm currently stuck w/ a dynamically changing ButtonGroup. I do not want to hardcode the different radio modes but want to assign them based on feedback from the radio as those differ for each radio type.

This one works (hardcoded), see top button group in screenshot below:

modes_group = ValueListButtonGroup(
    label="Mode:",
    values=[
        ("FM", "FM"),
        ("DAB", "DAB"),
        ("Internet radio", "Internet radio"),
    ],
).connect(mode_var)
radio_page.add_item(modes_group)

This one fails, triggered once the radio values are published:

@modes_var.trigger
@shc.handler()
async def rebuild_modes(mode_list, origin):
    my_group = ValueListButtonGroup(
        label="Mode:", values=[(x.label, x.label) for x in mode_list]
    ).connect(mode_var)
    radio_page.add_item(my_group)

The [(x.label, x.label) for x in mode_list] corresponds to
[('Internet radio', 'Internet radio'), ('Podcasts', 'Podcasts'), ('DAB', 'DAB'), ('FM', 'FM'), ('Bluetooth', 'Bluetooth'), ('CD', 'CD'), ('USB', 'USB'), ('AUX in', 'AUX in')] so it is a superset to above hardcoded values.

See the bottom button group w/ spinners never gets updated even if the above button group is changed either by clicking or by changing it on the radio:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions