pythonipywidgetsvoila

In python notebook Change the height of a ipywidget


I am using ipywidgets in jupyterlab for displaying later on with voila.

In order to display information I create several text on containers

wd_EXTRA_output = widgets.Output(layout={'border': '1px solid black'})
with wd_EXTRA_output:
    print('Information will be displayed here... ')

I dont want to pass a 'height' at the moment of creating the Output widget.

How can I later on modify the height of that widget?

 wd_EXTRA_output(layout={'height': '200px'})

Note: I know I could have passed the height at the moment of creating the widget, but for particular reasons I cant do that.


Solution

  • When you directly change the python attributes of a widget the display will update automatically. So in this case you can do:

    wd_EXTRA_output.layout.height = '200px'
    

    you can also set the height to other valid html heights, e.g. '50%'