3

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!

mnstoddard
  • 63
  • 5

2 Answers2

2

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>')
Nandor Poka
  • 281
  • 1
  • 10
0

You may increase width = '400px')

itsergiu
  • 662
  • 6
  • 11