add status bar at the bottom
This commit is contained in:
parent
ed2e395e5f
commit
1a5ac7bb5a
9
hn.py
9
hn.py
@ -22,6 +22,10 @@ class Story:
|
|||||||
votes: int
|
votes: int
|
||||||
comments: int
|
comments: int
|
||||||
|
|
||||||
|
def footer(stdscr, content):
|
||||||
|
stdscr.addstr(curses.LINES-1, 0, content, curses.A_REVERSE)
|
||||||
|
|
||||||
|
|
||||||
def main(stdscr):
|
def main(stdscr):
|
||||||
stdscr.clear()
|
stdscr.clear()
|
||||||
|
|
||||||
@ -36,8 +40,8 @@ def main(stdscr):
|
|||||||
stories = []
|
stories = []
|
||||||
for idx, i in enumerate(ids):
|
for idx, i in enumerate(ids):
|
||||||
stdscr.clear()
|
stdscr.clear()
|
||||||
stdscr.addstr(f'{num_stories}\n')
|
#stdscr.addstr(f'[{spinner_states[idx%4]}] Getting stories...')
|
||||||
stdscr.addstr(f'[{spinner_states[idx%4]}] Getting stories...')
|
footer(stdscr, f'[{spinner_states[idx%4]}] Getting stories...')
|
||||||
stdscr.refresh()
|
stdscr.refresh()
|
||||||
story_url = f'https://hacker-news.firebaseio.com/v0/item/{i}.json'
|
story_url = f'https://hacker-news.firebaseio.com/v0/item/{i}.json'
|
||||||
s = requests.get(story_url).json()
|
s = requests.get(story_url).json()
|
||||||
@ -69,6 +73,7 @@ def main(stdscr):
|
|||||||
if i == current_pos:
|
if i == current_pos:
|
||||||
detail = f' by {story.author} | {story.comments} comments | {story.votes} points\n'
|
detail = f' by {story.author} | {story.comments} comments | {story.votes} points\n'
|
||||||
stdscr.addstr(detail)
|
stdscr.addstr(detail)
|
||||||
|
footer(stdscr, f'Loaded {num_stories} stories.')
|
||||||
|
|
||||||
stdscr.refresh()
|
stdscr.refresh()
|
||||||
c = stdscr.getch()
|
c = stdscr.getch()
|
||||||
|
Loading…
Reference in New Issue
Block a user