如何下车和放置ipywidgets [英] How to alight and place ipywidgets

查看:146
本文介绍了如何下车和放置ipywidgets的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法控制ipywidgets(在jupyter笔记本中)的放置和对齐?

Is there a way to control the placement and alignment of ipywidgets (inside jupyter notebook)?

from ipywidgets import widgets
from IPython.display import Javascript, display
event_type_ui = widgets.Text(value='open', description='Test Event')
platform_ui = widgets.Text(value='Android', description='Control Event')
display(event_type_ui)
display(platform_ui)

我想指定一个偏移量(以像素为单位?)以使标签适合并使两个控件垂直对齐.

I would like to specify an offset (in pixels?) to allow the label to fit and to have two controls aligned vertically.

推荐答案

经过一番摆弄,我能够得到这个:

After some fiddling, I was able to get this:

之前:

之后:

如果有兴趣,请在此处复制粘贴摘录:

Here is a copy-paste snippet, if interested:

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

align_kw = dict(
    _css = (('.widget-label', 'min-width', '20ex'),),
    margin = '0px 0px 5px 12px'
)
platform_ui = widgets.Dropdown(description = 'platform',options=['iPhone','iPad','Android'], **align_kw)
event_type_ui = widgets.Text(value='open', description='Test Event', **align_kw)
os_version_ui = widgets.Text(value='iOS9', description='Operating System', **align_kw)
refresh_ui = widgets.Checkbox(description='Force Refresh', **align_kw)

display(platform_ui,event_type_ui,os_version_ui,refresh_ui)

这篇关于如何下车和放置ipywidgets的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆