Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text wrapping in ipywidgets

I can't seem to get my widgets to wrap text.

This code:

import ipywidgets as widgets

test_layout = widgets.Layout(
    border='1px solid black',
    flex_flow = 'row wrap',
    width = '200px')

test_string = 'test test test test test test test test test test'

test_label = widgets.Label(value = test_string, layout=test_layout)

test_label

Outputs:

output

What am I missing? I have tried lots of different things, but none of them have worked!

like image 356
mnstoddard Avatar asked Oct 27 '25 13:10

mnstoddard


1 Answers

I had the same issue. I used an HTML widget instead like this:

import ipywidgets as widgets
widget = widgets.HTML(value= '<style>p{word-wrap: break-word}</style> <p>'+ [variable containing long text goes here] +' </p>')
like image 143
Nandor Poka Avatar answered Oct 30 '25 13:10

Nandor Poka