如何ipywidgets
为长文本字符串配置复选框,如下所示,
c = Checkbox(description=' this is some very long very long text',value=False)
而不是让文本被压缩并包裹在包含的 Jupyter 笔记本中?
谢谢!
如何ipywidgets
为长文本字符串配置复选框,如下所示,
c = Checkbox(description=' this is some very long very long text',value=False)
而不是让文本被压缩并包裹在包含的 Jupyter 笔记本中?
谢谢!
另一种选择是将其与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)
把这是带有复选框的单元格
from IPython.display import display, HTML
HTML('<style> .widget-hbox .widget-label { max-width:350ex; text-align:left} </style>')
它会改变宽度和对齐方式。
只需使用这个:
import ipywidgets as widgets
c = widgets.Checkbox(
description='This is some very long very long text',
value=False,
layout=widgets.Layout(width='100%'))
使用它来设置复选框左侧的宽度,并独立设置整体宽度
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