ipython / ipython/ipykernel

Allow comm message to be processed during cell execution

Ouverte
#65 4 commentaires 1 réaction 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
734
Forks
412
Merge moyen
1 j 5 h
PR mergées (30 j)
8

Description

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!

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.