Python curses not displaying colors, whereas C ncurses works fine

空扰寡人 提交于 2019-12-04 21:45:50

you need to add the following lines at the beginning to initialize colors

curses.start_color()
curses.use_default_colors()

You then need o initialize color pairs with

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

This will initialize the first pair to red foreground and white background for example. After that you use the int value you pass as the first arg in the function instead of curses.COLORS in curses.color_pair() and the colors will appear properly.

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