我正在尝试在我的ipython笔记本中创建2列CheckboxWidgets:
from IPython.html import widgets # Widget definitions
from IPython.display import display # Used to display widgets in the notebook
comps = ['A', 'B', 'C']
trigs = ['X', 'Y', 'Z']
components = []
for comp in comps:
components.append(widgets.CheckboxWidget(description = comp, value=False))
comp_container = widgets.ContainerWidget(children = components)
comp_container.add_class('vbox')
comp_container.add_class("align-start")
triggers = []
for trig in trigs:
triggers.append(widgets.CheckboxWidget(description = trig, value=False))
trig_container = widgets.ContainerWidget(children = triggers)
trig_container.add_class('vbox')
trig_container.add_class("align-end")
main_container = widgets.ContainerWidget(children = [comp_container, trig_container])
main_container.set_css({
'background': '#999999',
'width': '100%',
})
main_container.remove_class('vbox')
main_container.add_class("hbox")
display(main_container)
不幸的是,这产生了:
http://i.stack.imgur.com/MgyXl.png
是否可以并排显示2个复选框列表?
答案 0 :(得分:2)
是。我不完全理解为什么行为是这样的,但是你需要在显示小部件之后更改css类'vbox'
和'hbox'
:
...
display(main_container)
main_container.remove_class('vbox')
main_container.add_class("hbox")