如何为复选框小部件获取更宽的文本?
How to get wider text for Checkbox widget?
如何为长文本字符串配置 ipywidgets
复选框,如
c = Checkbox(description=' this is some very long very long text',value=False)
没有让文本被挤压和包裹在包围的 Jupyter 笔记本中?
谢谢!
把这个放在有复选框的单元格中
from IPython.display import display, HTML
HTML('<style> .widget-hbox .widget-label { max-width:350ex; text-align:left} </style>')
它会改变宽度和对齐方式。
另一种选择是将其与 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)
只需使用这个:
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
如何为长文本字符串配置 ipywidgets
复选框,如
c = Checkbox(description=' this is some very long very long text',value=False)
没有让文本被挤压和包裹在包围的 Jupyter 笔记本中?
谢谢!
把这个放在有复选框的单元格中
from IPython.display import display, HTML
HTML('<style> .widget-hbox .widget-label { max-width:350ex; text-align:left} </style>')
它会改变宽度和对齐方式。
另一种选择是将其与 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)
只需使用这个:
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