Implement Footer. Implement fetching articles on start.

master
VikingKong 3 years ago
parent 82997192b3
commit 422365724e

@ -1,7 +1,6 @@
import requests
class Fetcher:
def __init__(self, URL, token):
self.URL = URL

@ -171,7 +171,8 @@ class TUI(urwid.Frame):
def create(cls):
tui = cls()
palette = [("text", "dark cyan", "dark cyan"), ('header', 'white', 'black'), ('reveal focus', 'black', 'dark cyan', 'standout')]
palette = [("linebox", "dark blue", "black"), ("text", "dark cyan", "dark cyan"),
('header', 'white', 'black'), ('reveal focus', 'black', 'dark cyan', 'standout')]
loop = urwid.MainLoop(
tui,
palette,
@ -199,39 +200,43 @@ class TUI(urwid.Frame):
self.articleView = RightPane([])
self.leftBox = urwid.LineBox(self.feedView, title="Categories")
self.rightBox = urwid.LineBox(self.articleView, title="Articles")
self.container = urwid.Columns(
self.views = urwid.Columns(
[(40, self.leftBox), self.rightBox])
self.status = urwid.Text("")
self.footer = urwid.ListBox([self.status])
self.container = urwid.Pile([self.views, (1, self.footer)])
self.body = self.container
self.articles = []
super().__init__(self.body)
def fetchAll(self):
articles = tui.fetcher.fetch()
for text in articles:
self.status.set_text(text)
tui.loop.entering_idle()
self.status.set_text("")
self.loop.event_loop.remove_alarm(self.handle)
def run(self):
focus_widget, idx = self.feedView.get_focus()
item = focus_widget.attr_map[None][0][13:]
self.fetcher.articlesFromCategory(item, str(focus_widget.attr_map[None][1]))
self.articles = tui.fetcher.articles[item]
self.articleView.fill(self.articles)
self.handle = self.loop.event_loop.alarm(0, self.fetchAll)
self.loop.run()
tui.loop.event_loop.remove_enter_idle(self.handle)
self.executor.shutdown(wait=False)
def unhandled_input(self, key):
if key == "tab":
self.activePane = not self.activePane
self.container.set_focus(int(self.activePane))
self.views.set_focus(int(self.activePane))
elif key == "q":
raise urwid.ExitMainLoop()
elif key == "r":
olb = urwid.ListBox(urwid.SimpleListWalker([urwid.Text("")]))
overlay = urwid.Overlay(
urwid.LineBox(olb),
self.body, align="center", width=("relative", 50), valign="middle", height=3)
self.body = overlay
articles = tui.fetcher.fetch()
for text in articles:
olb.body = urwid.SimpleListWalker([urwid.Text(text)])
tui.loop.entering_idle()
self.body = overlay.bottom_w
self.fetchAll()
focus_widget, idx = self.feedView.get_focus()
itemId = focus_widget.attr_map[None][0]
self.articles = tui.fetcher.articles[itemId[13:]]

@ -9,6 +9,7 @@ class Article:
self.currentPageNumber = 1
terminal_width, terminal_height = os.get_terminal_size()
terminal_width -= 60
terminal_height -= 1
start_of_chunk = 0
end_of_chunk = 0
rows_passed = 0

Loading…
Cancel
Save