def write_scr(stdscr, wallet, y, x):
'''Write text and formatting to screen'''
first_pad = '{:>{}}'.format('', CONFIG['theme'].getint('dec_places', 2) + 10 - 3)
second_pad = ' ' * (CONFIG['theme'].getint('field_length', 13) - 2)
third_pad = ' ' * (CONFIG['theme'].getint('field_length', 13) - 3)
if y >= 1:
stdscr.addnstr(0, 0, 'cryptop v0.2.0', x, curses.color_pair(2))
if y >= 2:
header = ' COIN{}PRICE{}HELD {}VAL{}HIGH {}LOW '.format(first_pad, second_pad, third_pad, first_pad, first_pad)
stdscr.addnstr(1, 0, header, x, curses.color_pair(3))
total = 0
coinl = list(wallet.keys())
heldl = list(wallet.values())
if coinl:
coinvl = get_price(','.join(coinl))
if y > 3:
s = sorted(list(zip(coinl, coinvl, heldl)), key=SORT_FNS[SORTS[COLUMN]], reverse=ORDER)
coinl = list(x[0] for x in s)
coinvl = list(x[1] for x in s)
heldl = list(x[2] for x in s)
for coin, val, held in zip(coinl, coinvl, heldl):
if coinl.index(coin) + 2 < y:
stdscr.addnstr(coinl.index(coin) + 2, 0,
str_formatter(coin, val, held), x, curses.color_pair(2))
total += float(held) * val[0]
if y > len(coinl) + 3:
stdscr.addnstr(y - 2, 0, 'Total Holdings: {:10} '
.format(locale.currency(total, grouping=True)), x, curses.color_pair(3))
stdscr.addnstr(y - 1, 0,
'[A] Add/update coin [R] Remove coin [S] Sort [C] Cycle sort [0\Q]Exit', x,
curses.color_pair(2))
评论列表
文章目录