# Interactive widgets while executing long-running cell

**URL:** <https://discourse.jupyter.org/t/interactive-widgets-while-executing-long-running-cell/2537>\
**Category:** JupyterLab\
**Created:** [October 26, 2019, 12:13pm UTC](https://discourse.jupyter.org/t/interactive-widgets-while-executing-long-running-cell/2537 "2019-10-26T12:13:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kirill888](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/kirill888/32/598_2.png) [@Kirill888](https://discourse.jupyter.org/u/Kirill888)\
**Post date:** [October 26, 2019, 12:13pm UTC](https://discourse.jupyter.org/t/interactive-widgets-while-executing-long-running-cell/2537/1 "2019-10-26T12:13:41Z")

</div>

Hi,

I want to share a small library I developed that allows interaction with `ipywidgets` inside lab or notebook environments while executing a long-running cell.

I chose the name `jupyter-ui-poll`. Library is open source, on [github](https://github.com/Kirill888/jupyter-ui-poll), and available for installation from [PyPi](https://pypi.org/project/jupyter-ui-poll/).

So why is it needed?

By default UI events are not processed while code inside a notebook cell is executing, Javascript events do run, but not python callbacks. This makes it impossible to implement user interfaces that block execution of the rest of the notebook while waiting for input from the user.

This behaviour is often desirable however. In geospatial applications in particular selecting a region on a map at the start of the notebook, then running the rest, is a commonly requested feature. While this is possible to achieve with current tools, the experience is a bit sub-par, as it requires instructing the notebook user to **not** execute subsequent cells until desired input is provided.

I wanted to be able to write notebooks that use highly interactive user inputs, like `ipyleaflet`, while still maintaining a typical linear workflow. And I wanted to be able to run those notebooks with `Run All` without any issues.

While researching on how to achieve this I came across [`ipython_blocking`](https://github.com/kafonek/ipython_blocking) library that addresses similar issue. Ultimately it did no quite suit my needs, but it did provide a starting point for my own implementation, so I thought it’s important to reference it.

You can install it with `pip`:

`pip install jupyter-ui-poll`

Or play with it in [binder](https://mybinder.org/v2/gh/kirill888/jupyter-ui-poll/master?filepath=notebooks%2FExamples.ipynb).
