modules/packages in an @interact

33 views
Skip to first unread message

jk...@clarkson.edu

unread,
May 24, 2017, 2:31:53 PM5/24/17
to sage-devel
I would like to re-use and organize code over multiple "interacts".  In python this is done via modules/packages.  Specifically, I request advise on how to do the following -
1.) define functions and put them in an appropriately named file.
2.) tell the html page that is running an "interact" where these functions are.
3.) put instructions in the "interact" to load/use these functions so that they would be available in the "interact".

Advise on this would be very much appreciated.  Thank you.

Jim Kane

Jeroen Demeyer

unread,
May 25, 2017, 3:40:20 AM5/25/17
to sage-...@googlegroups.com
I don't fully understand what you want to do, but please have a look at
src/sage/interacts
There, various interacts are defined which can be called by the user. It
works both in SageNB and Jupyter. I guess your package could do
something similar.

If you only care about Jupyter, there are other solutions too: in
Jupyter, an "interact" is just an object which can be displayed. You
create such an object with:

def interactive_function(...):
...

w = interact.widget(interactive_function)

After this, w will be the interact object. Just defining it in this way
does not display it.
Reply all
Reply to author
Forward
0 new messages