Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the Collapse widget #1926

Open
jasongrout opened this issue Jan 23, 2018 · 7 comments
Open

Expose the Collapse widget #1926

jasongrout opened this issue Jan 23, 2018 · 7 comments
Milestone

Comments

@jasongrout
Copy link
Member

jasongrout commented Jan 23, 2018

The accordion widget is basically a vbox of Collapse widgets, with the added logic that only one collapse widget can be open at a time. We should also expose the single Collapse widget, so it's easy for people to have a single collapse widget, or multiple open, etc.

Basically, we need to expose the Collapse widget defined in https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/controls/src/phosphor/accordion.ts, perhaps with a new widget, like a new box widget in https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/controls/src/widget_box.ts.

@jasongrout jasongrout added this to the Future milestone Jan 23, 2018
@jasongrout
Copy link
Member Author

As a workaround (and maybe good enough?), an accordion widget with one child is essentially this collapse widget.

@vishma
Copy link

vishma commented Mar 11, 2019

Hi,
I need to make all the accordions to be collapsed when the notebook starts. Is it possible from the notebook itself?

@whiteboxbatteries
Copy link

@jasongrout +1

As a workaround (and maybe good enough?), an accordion widget with one child is essentially this collapse widget.

@vishma
Yes, you can do it like this.

import ipywidgets as widgets

slider = widgets.SelectionSlider(
    options=['How', 'do', 'you', 'like', 'it?'],
    value='How',
    disabled=False,
    continuous_update=False,
    orientation='horizontal',
    readout=True
)

left = widgets.Accordion([slider])
left.set_title(0, 'Left')

right = widgets.Accordion([slider])
right.set_title(0, 'Right')

top = widgets.Accordion([slider])
top.set_title(0, 'Top')

center = widgets.Accordion([slider])
center.set_title(0, 'Center')

bottom = widgets.Accordion([slider])
bottom.set_title(0, 'Bottom')

app = widgets.HBox([
    left,
    widgets.VBox([
        top,
        center,
        bottom,
    ]),
    right,
])

app
# Collapse all
left.selected_index = None
right.selected_index = None
top.selected_index = None
center.selected_index = None
bottom.selected_index = None
# Expand all
left.selected_index = 0
right.selected_index = 0
top.selected_index = 0
center.selected_index = 0
bottom.selected_index = 0

Accordion_collapse.zip

@ankostis
Copy link

ankostis commented Sep 11, 2019

Forgive my ignorance, but is this issue for having (optionally) many widgets visible at the same time in an Accordion?

@jasongrout
Copy link
Member Author

Essentially, yes.

@ankostis
Copy link

ankostis commented Sep 11, 2019

Thank you. You may include this user-facing functionality in the title, if you wish (and keep the current title for the PR).

@marscher
Copy link

marscher commented Jul 28, 2023

@jasongrout
Having the possibility of multiple opened/selected indices would be awesome! It would allow the user to focus on sub-elements of the GUI. I wonder if this change would be ported to major version 7.

would it be possible to change the allowed traits for selected_index for Accordion to a list/tuple? And just delegate this change to frontend. Should be backwards compatible and allow for multiple selection, am I wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants