# Is it possible to get the current value of a widget slider from a function without using multithreading?

**URL:** https://discourse.jupyter.org/t/is-it-possible-to-get-the-current-value-of-a-widget-slider-from-a-function-without-using-multithreading/15524
**Category:** Widgets
**Tags:** how-to, help-wanted
**Created:** [August 26, 2022, 8:54am UTC](https://discourse.jupyter.org/t/is-it-possible-to-get-the-current-value-of-a-widget-slider-from-a-function-without-using-multithreading/15524 "2022-08-26T08:54:21Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![bollwyvl](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/bollwyvl/32/904_2.png) [@bollwyvl](https://discourse.jupyter.org/u/bollwyvl)
#### Post date: [August 26, 2022, 9:46pm UTC](https://discourse.jupyter.org/t/is-it-possible-to-get-the-current-value-of-a-widget-slider-from-a-function-without-using-multithreading/15524/2 "2022-08-26T21:46:29Z")

</div>

Inside a modern ipython/ipykernel, you’ll pretty much always be inside an asyncio-compatible event loop. If you block, though, then things stop flowing.

`Output` is kind of an implementation nightmare, with each frontend being slightly different. However, `display(..., display_id=True).update` works great.

So:

```python
import ipywidgets as widgets
import asyncio

slider = widgets.IntSlider(
    value=5,
    min=0,
    max=10,
    step=1,
    description='Test:',
    disabled=False,
    continuous_update=False,
    orientation='horizontal',
    readout=True,
    readout_format='d'
)

async def test(slider, output):
    i = 0
    while slider.value != 10:
        i = i+1
        await asyncio.sleep(0.1)
        output.update('test ' + str(slider.value) + ' - ' + str(i))

output = display("tbd", display_id=True)
display(slider)

asyncio.create_task(test(slider, output));

```

Related: [Threading with Matplotlib and ipywidgets - #2 by bollwyvl](https://discourse.jupyter.org/t/threading-with-matplotlib-and-ipywidgets/14674/2)

---

_[View the full topic](https://discourse.jupyter.org/t/is-it-possible-to-get-the-current-value-of-a-widget-slider-from-a-function-without-using-multithreading/15524)._
