ipywidgets中的文字换行

问题描述 投票:0回答:1

我似乎无法获得用于包装文本的小部件。

此代码:

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

输出:

output

我想念的是什么?我尝试了很多不同的方法,但是没有一个起作用!

word-wrap ipywidgets
1个回答
0
投票

我有同样的问题。我改用了HTML小部件,如下所示:

import ipywidgets as widgets
widget = widgets.HTML(value= '<style>p{word-wrap: break-word}</style> <p>'+ [variable containing long text goes here] +' </p>')
© www.soinside.com 2019 - 2024. All rights reserved.