3

I´m looking to align to the center a button object from the ipywidget function. Here´s a sample of the code I´m using

bt = widgets.Button(layout=Layout(width='180px'),style = 
    {'description_width': '25%'})
b_config_save = widgets.Button(
    description="Save",
    layout=bt.layout,
    style=bt.style,
    button_style='primary'
)
Lucas Mengual
  • 263
  • 6
  • 21

2 Answers2

10

Use a flexbox layout as shown below.

btn = widgets.Button(description="Save")
box_layout = widgets.Layout(display='flex',
                flex_flow='column',
                align_items='center',
                width='50%')
box = widgets.HBox(children=[btn],layout=box_layout)
display(box)
Vishma Dias
  • 630
  • 6
  • 11
  • Doc has moved, link doesn't point there anymore. [New link](https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Layout.html?#The-Flexbox-layout) – Battleman Sep 27 '22 at 09:11
0

Try to use table ,maybe you can find some help here