提问人:Sadra 提问时间:3/19/2022 最后编辑:Sadra 更新时间:5/20/2023 访问量:1962
在 VSCode Jupyter 笔记本中使 tqdm bar 变暗
make tqdm bar dark in VSCode Jupyter notebook
问:
我在启用了深色模式的 Visual Studio Code 中使用 Jupyter 笔记本。我用 tqdm 可视化进度条,但它没有显示为深色。看图片:
根据 GitHub 上的这个问题,这不是 Jupyter、ipywidget 或 tqdm 本身的问题,它只与 VSCode 有关。
有什么解决方法可以解决这个问题吗?
答:
0赞
SriSreedhar
4/10/2023
#1
您可以使用使用 ANSI 转义码设置颜色的自定义格式将 tqdm-bar_format 参数传递给 tqdm。
像这样的东西:
from tqdm import tqdm
import time
# Custom format with ANSI escape codes for dark green color
dark_green = "\033[1;32;40m"
bar_format = f"{dark_green}{{l_bar}}{{bar:50}} [{{elapsed}}]{{r_bar}}"
# Create tqdm progress bar with custom format
for i in tqdm(range(100), bar_format=bar_format):
time.sleep(0.01)
此外,This-Post 可能会有所帮助。
0赞
walksonair
5/20/2023
#2
我遇到了同样的问题,我的搜索显示,在单元格中单独输入以下内容可以解决背景显示问题,但文本变暗可能是深色背景上的问题。作为折衷方案,我将我的设置为桃色页面(见屏幕截图):
%%html
<style>
.cell-output-ipywidget-background {
background-color: transparent !important;
}
.jp-OutputArea-output {
background-color: transparent;
}
</style>
0赞
mentoc3000
11/29/2023
#3
这个答案对我有用。在单元格中运行下面的代码。
%%html
<style>
.cell-output-ipywidget-background {
background-color: transparent !important;
}
:root {
--jp-widgets-color: var(--vscode-editor-foreground);
--jp-widgets-font-size: var(--vscode-editor-font-size);
}
</style>
评论