[Python] ipywidgets widgets not launching

Discussão em 'Python' iniciado por Stack, Abril 6, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to write a python3 program that using widget to get input,

    import ipywidgets as widgets
    from IPython.display import display, clear_output

    def button_clicked(b):
    with output:
    clear_output()
    print("Button clicked!")

    button = widgets.Button(description="Click Me")
    output = widgets.Output()

    button.on_click(button_clicked)
    display(button, output)

    # Event Loop (for standalone Python scripts)
    try:
    while True:
    pass
    except KeyboardInterrupt:
    with output:
    print("Ended")


    but whatever I try the ipywidgets widgets package just writes "Button(description='Click Me', style=ButtonStyle()) Output()" to the screen and no button is launched.

    The code is a just an attempt to make a reproducible example. I'm on a MAC, python version 3.12.7 running in conda.

    Continue reading...

Compartilhe esta Página