Skip to content

Callable widget example is broken or maybe the widget #698

@OlaFosheimGrostad

Description

@OlaFosheimGrostad

Example code:
https://pyapp-kit.github.io/magicgui/generated_examples/applications/callable/

Version on macports:
py313-magicgui @0.10.0 (python)

Problem:
Shows double run buttons.

When I write my own example with default set to None, it shows the "run" button initially, but it disappears if I select "f" then None. A better behaviour would be for the run button to be disabled on None or remove it initially.

My testcode:

from magicgui import magicgui

def f(x:int, y:str) -> str:
    return f"f({x},{y})"

def g(x:int, y:int) -> str:
    return f"g({x},{y})"

@magicgui(call_button=True, func={"choices": ["f", "g"]})
def example(func=None):
    pass


def update(name: str):
    if len(example) > 1:
        del example[1]
    if name is not None:
        example.insert(1, magicgui(globals()[name]))

def main():
    example.func.changed.connect(update)
    example.show(run=True)

if __name__ == '__main__':
    main()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions