Is it possible to get the default background color using curses in python?

时间秒杀一切 提交于 2019-12-05 18:42:06

Ok, I figured it out,

If you call init_pair with -1 as a value it will fill in the terminal default. For example to make red text with the default background:

curses.init_pair(1, curses.COLOR_RED, -1)

Now curses.color_pair(1) will be set to the background. This will even work if you change the terminal's default while the program is running.

You do have to call curses.use_default_colors() first to use this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!