Firilisinof
Firilisinof

Reputation: 35

Changing the layout of the ipython widgets toggle buttons

These are the buttons that I'm trying to customize: toggle buttons from ipywidgets

The code itself.


This is the result I want to get (edited by GIMP):

edit


I want to keep these buttons stacked vertically (as shown in the edited image I made), but since I don't know much about CSS, I don't know how to do that. Any suggestion?

Upvotes: 1

Views: 1659

Answers (2)

Rub
Rub

Reputation: 2708

As Bananach said, layout=widgets.Layout(width='100px') will do it.

widgets.ToggleButtons(
    options=['A','B', 'C'],
    disabled=False,
    button_style='info', # 'success', 'info', 'warning', 'danger' or ''
    layout=widgets.Layout(width='100px')
    #     icons=['check'] * 3
)

enter image description here

Upvotes: 2

Bananach
Bananach

Reputation: 2311

I don't know how to do this explicitly, but if you pass layout=dict(width='200px') to the ToggleButtons constructor, the widget will automatically stack the buttons vertically to be able to fit them in the given width.

Upvotes: 0

Related Questions