Allow comm message to be processed during cell execution
- Linguagem predominante
- Python
- Estrelas
- 734
- Forks
- 412
- Merge médio
- 1d 5h
- PRs com merge (30d)
- 8
Descrição
The use case: a Python function getMouse() that blocks waiting for the user to click on an SVG image that has been wired up to a trait to pass the x,y value back to Python. We would like getMouse() to return that x,y.
The implementation we are thinking of would allow comm messages to be processed during the cell execution. I think this is general to any comm_msg, but our goal is just the mouse widget. Here is a little version of the idea:
``` python
from ipywidgets import widgets
from IPython.display import display
i = widgets.IntText()
display(i)
i.value = 78
while i.value == 78:
pass
```
We would like to be able to change the value in the displayed IntText (for example) and have the loop stop when the detected value changes. We understand that jupyter is not designed to do this, but we would like to replicate a pre-existing API in the notebook, getMouse().
Is it possible, while the cell is executing, to process any queued comm messages? Thinking of something like:
``` python
while i.value == 78:
kernel = get_ipython_kernel()
kernel.process_comm_msgs()
```
Any help or alternative ideas welcomed!
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.