Recursively building complex custom widget from javascript side

37 views
Skip to first unread message

Marine

unread,
Dec 26, 2018, 9:35:00 AM12/26/18
to Project Jupyter
Hello everyone,


I am currently working on a custom "list" widget where it is possible to append identical (duplicates) widget to the main widget.

I am struggling to get the initial state message from the kernel sent immediately after the comm-open message to be considered before I update the widget model.

In practice in debug mode using breakpoints I see my widget appear progressively but then the message "I don't have any children" is received and the model is updated with the value children={}.

The widget extends the Box widget.

Exemple of use: 
test=ListAccordion(children=[Box(children=[Box(children=[Button(), IntSlider()]), IntSlider()])],layout=Layout(align_items='stretch', display='flex', flex_flow='column', width='available'))
display(test)

This is my code that recursively duplicates and appends the children widget to the custom "list" widget when the user clicks on the "+" button.


Javascript:

Python:


I would be very grateful if one of you could help me with that !


Thanks a lot


Marine

Aaron Watters

unread,
Jan 10, 2019, 2:04:16 PM1/10/19
to Project Jupyter
An alternative approach would be to build the interaction you want using "stand alone javascript" with
any support library you want (like jQueryUI) and then connect the javascript component to Jupyter
using proxy widgets.  That is how I would approach it (but I'm a bit biased ;c) ).

Please see the proxy widget tutorial on how to do this.


Let me know if you have questions.  -- Aaron Watters
Reply all
Reply to author
Forward
0 new messages