John Mee
John Mee

Reputation: 52253

How to show more rows in selectMultiple widget?

How might one tell the selectMultiple widget to show more rows?

widgets.SelectMultiple(
    options=GROUP_NAMES,
    description='Groups',
    disabled=False,
)

The html equivalent of adding a size attribute size=10 to the select tag.

Not this but that...

defaults to 3 rows

but we want lots of rows

Upvotes: 3

Views: 4654

Answers (2)

KnightShadeX
KnightShadeX

Reputation: 108

The issue was resolved with ipywidgets version 7.0 back in mid-late 2017. You can now use

widgets.SelectMultiple(
    options=GROUP_NAMES,
    description='Groups',
    rows=len(GROUP_NAMES)
    layout=Layout(width="100%")

And set both the width and the number of rows visible.

Upvotes: 6

Ryan
Ryan

Reputation: 31

I am pretty sure this is broken as the height and width parameters affect the surrounding <div> tags and not the the widget (see https://github.com/jupyter-widgets/ipywidgets/issues/1133).

For now, if you want the box to resize to match the width and height of the containing items you can change the layout to flex.

widgets.SelectMultiple(
    options=GROUP_NAMES,
    description='Groups',
    layout=Layout(display="flex", flex_flow='column')
)

The height argument appears to work if you do this, and the width works in your original example.

Upvotes: 3

Related Questions