4

如何ipywidgets为长文本字符串配置复选框,如下所示,

 c = Checkbox(description=' this is some very long very long text',value=False)

而不是让文本被压缩并包裹在包含的 Jupyter 笔记本中?

谢谢!

4

4 回答 4

1

另一种选择是将其与Label

from ipywidgets import widgets, Layout
from IPython.display import display

checkbox = widgets.Checkbox(value=False, disabled=False, layout=Layout(width='30px'))
label = widgets.Label('description', layout=Layout(width='500px', margin='6px 0 0 -10px'))
box = widgets.HBox([checkbox, label])
display(box)
于 2017-08-08T23:04:32.767 回答
0

把这是带有复选框的单元格

from IPython.display import display, HTML
HTML('<style> .widget-hbox .widget-label { max-width:350ex; text-align:left} </style>')

它会改变宽度和对齐方式。

于 2016-10-19T00:54:33.763 回答
0

只需使用这个:

import ipywidgets as widgets

c = widgets.Checkbox(
    description='This is some very long very long text',
    value=False,
    layout=widgets.Layout(width='100%'))
于 2021-07-01T09:40:57.680 回答
0

使用它来设置复选框左侧的宽度,并独立设置整体宽度

import ipywidgets as widgets

c = widgets.Checkbox(
    description=' this is some very long very long text',
    value=False)
c.style = {'description_width': '0px'}  # sets the width to the left of the check box
c.layout.width = 'auto' # sets the overall width check box widget
c
于 2021-11-01T15:31:22.507 回答