How to use the idom.Input function in idom

To help you get started, we’ve selected a few idom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rmorshea / idom / tests / test_widgets / test_input.py View on Github external
def test_input_cast_and_ignore_empty(driver, driver_wait, display):
    # ignore empty since that's an invalid float
    change_occured = Event()

    inp = idom.Input("number", 1, {"id": "inp"}, cast=float, ignore_empty=True)

    @inp.events.on("change")
    async def on_change(event):
        change_occured.set()

    display(inp)

    client_inp = driver.find_element_by_id("inp")
    assert client_inp.get_attribute("value") == "1"

    send_keys(client_inp, Keys.BACKSPACE)
    time.sleep(0.1)  # waiting and deleting again seems to decrease flakiness
    send_keys(client_inp, Keys.BACKSPACE)

    assert change_occured.wait(timeout=3.0)
    assert client_inp.get_attribute("value") == ""
github rmorshea / idom / tests / test_widgets / test_input.py View on Github external
async def UpdateImmediately(self):
        inp = idom.Input("text", "initial-value", {"id": "inp"})
        inp.update("new-value")
        return inp
github rmorshea / idom / tests / test_widgets / test_input.py View on Github external
def test_input(driver, driver_wait, display):
    inp = idom.Input("text", "initial-value", {"id": "inp"})

    display(inp)

    client_inp = driver.find_element_by_id("inp")
    assert client_inp.get_attribute("value") == "initial-value"

    client_inp.clear()
    send_keys(client_inp, "new-value-1")
    driver_wait.until(lambda dvr: inp.value == "new-value-1")

    client_inp.clear()
    send_keys(client_inp, "new-value-2")
    driver_wait.until(lambda dvr: client_inp.get_attribute("value") == "new-value-2")
github rmorshea / idom / docs / source / widgets / matplotlib_animation.py View on Github external
def linked_inputs(label, value, *types, **attributes):
    var = idom.Var(value)

    inputs = []
    for tp in types:
        inp = idom.Input(tp, value, attributes, cast=float)

        @inp.events.on("change")
        async def on_change(event, inp=inp):
            for i in inputs:
                i.update(inp.value)
            var.set(inp.value)

        inputs.append(inp)

    fs = idom.html.fieldset(
        {"class": "linked-inputs"},
        [idom.html.legend({"style": {"font-size": "medium"}}, label)],
        inputs,
    )

    return var, fs