Jupyter notebook 下拉宽度
Jupyter notebook Dropdown width
我正在使用 ipywidgets 下拉菜单 class 在 Jupyter 笔记本中放置一个下拉小部件,如下所示:
import ipywidgets as widgets
from IPython.display import display
ids = ['This is a very long string that is too long for the box',
'This is another very long string that is too long as well',
'The more, the merrier: One last long string that identifies something']
current = widgets.Dropdown(options=ids, value=ids[0],
description='Current dataset:', width='500px')
display(current)
下拉字段本身对于长字符串来说已经足够宽了,但是当打开选项列表时,这个列表的宽度太小并且不遵循声明中给定的 'width' 参数 (见图片)。
有没有办法设置下拉菜单选项列表的宽度?我希望它足够宽以显示整个字符串。
我将问题追溯到 CSS 属性 width:calc(275px)
:
.dropdown-menu{
max-height:200px;
overflow:hidden;
overflow-y:auto;
width:calc(275px)
}
这是我在 extension.js
中的 <install_dir>/anaconda/share/jupyter/nbextensions/jupyter-js-widgets
。删除 width
属性可以解决问题。我试图在 GitHub 查看源代码,但无法弄清楚它的来源。
我正在使用 ipywidgets 下拉菜单 class 在 Jupyter 笔记本中放置一个下拉小部件,如下所示:
import ipywidgets as widgets
from IPython.display import display
ids = ['This is a very long string that is too long for the box',
'This is another very long string that is too long as well',
'The more, the merrier: One last long string that identifies something']
current = widgets.Dropdown(options=ids, value=ids[0],
description='Current dataset:', width='500px')
display(current)
下拉字段本身对于长字符串来说已经足够宽了,但是当打开选项列表时,这个列表的宽度太小并且不遵循声明中给定的 'width' 参数 (见图片)。
有没有办法设置下拉菜单选项列表的宽度?我希望它足够宽以显示整个字符串。
我将问题追溯到 CSS 属性 width:calc(275px)
:
.dropdown-menu{
max-height:200px;
overflow:hidden;
overflow-y:auto;
width:calc(275px)
}
这是我在 extension.js
中的 <install_dir>/anaconda/share/jupyter/nbextensions/jupyter-js-widgets
。删除 width
属性可以解决问题。我试图在 GitHub 查看源代码,但无法弄清楚它的来源。