def print_stock_data(col, row, data, title, scr_main, scr_strip, cursor_row, change_amount, scr_dim):
scr_strip.addstr(0, col+10, title)
data_length = len(str(data))
spaces_length = 9 - data_length
n = 0
if col+10+18 > scr_dim[1]:
spaces_length = spaces_length + scr_dim[1] - col-10-9
while n < spaces_length:
data = data + " "
n = n + 1
curses.start_color()
curses.init_pair(8, curses.COLOR_BLACK, curses.COLOR_RED)
curses.init_pair(9, curses.COLOR_BLACK, curses.COLOR_GREEN)
curses.init_pair(10, curses.COLOR_BLACK, curses.COLOR_YELLOW)
curses.init_pair(11, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(12, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(13, curses.COLOR_YELLOW, curses.COLOR_BLACK)
if cursor_row == 1:
if change_amount == -1:
scr_main.addstr(row, col, data, curses.color_pair(8))
elif change_amount == 1:
scr_main.addstr(row, col, data, curses.color_pair(9))
else:
scr_main.addstr(row, col, data, curses.color_pair(10))
else:
if change_amount == -1:
scr_main.addstr(row, col, data, curses.color_pair(11))
elif change_amount == 1:
scr_main.addstr(row, col, data, curses.color_pair(12))
else:
scr_main.addstr(row, col, data, curses.color_pair(13))
评论列表
文章目录