python - Curses 背景颜色在 iTerm2 中无法使用 TERM=xterm 工作

标签 python curses iterm2

我有以下代码,它使用 curses 绘制一个带有消息的小窗口。

import curses
import time

screen = curses.initscr()
curses.start_color()
curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
window = curses.newwin(15, 60)
window.bkgd(' ', curses.color_pair(1))
window.addstr(7, 1, 'Hello')
window.refresh()
time.sleep(2)
curses.endwin()

我希望背景颜色为蓝色,但该行为在 iTerm2 中并不一致。使用 TERM=screen ,我得到了预期的输出: enter image description here

TERM=xterm 时,不会绘制空格: enter image description here

如果我使用不同的字符作为背景,它就会正确绘制。可能是什么问题?

我使用的是 Python 3 和 iTerm2 3.0。

最佳答案

问题在于 tmux 不支持 xterm 终端描述中假定的“背景色删除”功能。

进一步阅读:

关于python - Curses 背景颜色在 iTerm2 中无法使用 TERM=xterm 工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43214987/

相关文章:

python - TensorFlow InvalidArgumentError 在读取记录以在自己的图像集上进行训练时出现错误

python - 使用 (n)curses 打印到终端的右侧或底部

Python curses 不显示颜色,而 C ncurses 工作正常

macos - 如何使用 Shift+Arrow 在 iterm 中选择文本?

python - 警告 'Empty filters detected in mel frequency basis. ' 是关于什么的?

python - tensorflow的mod运算符可以匹配python的modulo实现吗?

python - 计算吸收马尔可夫链的基本矩阵的最佳方法?

c - C 中使用 ncursesw 输出 "█"

applescript - iTerm applescript 在两个单独的垂直 Pane 中写入

linux - 输入 'ls' 命令时,我得到 'zsh: command not found: gls'