I observe a strange problem while running below code in gnome-terminal in a RHE6 linux machine.
Code snippet:
import curses
def main(stdscr):
if curses.has_colors():
curses.start_color()
curses.use_default_colors()
for i in range(0, curses.COLORS):
#curses.init_pair(i+1, 253, i) # opt2
curses.init_pair(i+1, i, 253) # opt1
try:
#stdscr.bkgd(' ', curses.color_pair(8) | curses.A_REVERSE) # opt2
stdscr.bkgd(' ', curses.color_pair(8)) # opt1
for i in range(0, curses.COLORS):
stdscr.addstr(str(i), curses.color_pair(i))
except:
print('Exception caught')
stdscr.refresh()
stdscr.getch()
curses.wrapper(main)
If i run this code ( as it is ) in Xterm, it works as expected and gives me a grey background. But if i run it in gnome terminal, it gives the default terminal background in all places where there is no character written. Wherever there is a character printed, it applies the correct background color.
if i use any other character instead of space (say, bkgd('.', attr)
) in the bkgd
command, then the background is applied correctly
If i were to comment out the #opt1
lines and uncomment #opt2
lines, then it is applying the background correctly in both xterm and gnome-terminal. ( I can't use this method because in the real program, I want to enable support for REVERSE printing. )
I'm testing with python 3.4 in linux ( both the case of xterm and gnome-terminal )
it is behaving as i wanted in my OS X terminal with python 3.5 - but i think this has nothing to do with python version. My test with python 2.6 on the linux machine showed same behaviors as in 3.4.
I have a custom theme in gnome-terminal.
if anyone has any clue on this problem, that would be really helpful! Thank you all in advance!