Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ipywidget Accordion default behaviour

Ipywidget accordion is expanded by default when the notebook is executed for the first time. How to make the accordion collapsed by default ?

Thanks in Advance.

like image 625
Vishma Dias Avatar asked Jan 01 '23 05:01

Vishma Dias


1 Answers

Set selected_index = None when creating the Accordion.

from ipywidgets import Accordion, FloatSlider
acc = Accordion(children=[FloatSlider()], selected_index=None)
display(acc)

enter image description here

like image 138
ac24 Avatar answered Jan 13 '23 16:01

ac24