如何在浏览器中增加Jupyter/ipython笔记本的单元格宽度?

2024-05-16 08:06:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在浏览器中增加ipython笔记本的宽度。我有一个高分辨率的屏幕,我想扩大单元格的宽度/大小以利用这个额外的空间。

谢谢!


编辑:5/2017

我现在使用jupyterthemes:https://github.com/dunovank/jupyter-themes

这个命令:

jt -t oceans16 -f roboto -fs 12 -cellw 100%

它将宽度设置为100%,主题很好。


Tags: httpsgithubcom编辑利用宽度屏幕ipython
3条回答

为了让它与jupyter(4.0.6版)一起工作,我创建了~/.jupyter/custom/custom.css,其中包含:

/* Make the notebook cells take almost all available width */
.container {
    width: 99% !important;
}   

/* Prevent the edit cell highlight box from getting clipped;
 * important so that it also works when cell is in edit mode*/
div.cell.selected {
    border-left-width: 1px !important;
}

如果不想更改默认设置,而只想更改当前笔记本的宽度,则可以在单元格中输入以下内容:

from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))

这个div.cell解决方案实际上并不适用于我的IPython,不过幸运的是有人为新IPythons建议了一个有效的解决方案:

创建包含内容的文件~/.ipython/profile_default/static/custom/custom.css(iPython)或~/.jupyter/custom/custom.css(Jupyter)

.container { width:100% !important; }

然后重新启动iPython/Jupyter笔记本。请注意,这将影响所有笔记本电脑。

相关问题 更多 >