[IPython-dev] Nested and blocking calls of Interact or Interactive

Brian E Chapman Brian.Chapman at utah.edu
Fri Jun 19 17:00:48 EDT 2015


Here in a nutshell is what I’m trying to do.

Iterate over (or select from a dropdown widget) a list of directories corresponding to medical imaging exams
For the selected directory (exam) select a subdirectory (image series)
For the selected series
Read in the image
interactively define a bounding box in the image using IntRangeSlider

Since interactive doesn’t block, I can’t work it into a loop. On the other hand, I haven’t been able to get an interactive widget to generate another interactive widget.

Brian

From: Thomas Kluyver <takowl at gmail.com<mailto:takowl at gmail.com>>
Reply-To: IPython developers list <ipython-dev at scipy.org<mailto:ipython-dev at scipy.org>>
Date: Friday, June 19, 2015 at 12:07 PM
To: IPython developers list <ipython-dev at scipy.org<mailto:ipython-dev at scipy.org>>
Subject: Re: [IPython-dev] Nested and blocking calls of Interact or Interactive

On 19 June 2015 at 10:20, Brian E Chapman <Brian.Chapman at utah.edu<mailto:Brian.Chapman at utah.edu>> wrote:
First, is it possible to use interactive in a nested manner. That is, I have one function that I call with interactive and this function in turn calls another function with interactive?

Second, can you call interactive such that execution is blocked until the widget is closed? For example, I would like to call create/execute an interactive widget within a loop.

Widgets can't pause code, and the kernel won't process widget updates while the kernel is running in the main thread. You could probably hack something together using generators and/or threads to make it look like it was doing that, but I wouldn't recommend it.

Can you describe at a higher level what you're trying to do - we might be able to suggest other ways to achieve it.

Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20150619/db802718/attachment.html>


More information about the IPython-dev mailing list