Decouple widgets view logic and content-aware (controller) logic (we're doing MVC)
Some widgets (namely Menu
and ArticleList
) shouldn't be aware of provider and should be just "stupid" display widgets, i.e. should provide interface like set_feeds()
, set_articles()
, add_articles()
, ... Currently they're not stupid at all - they make autonomous decisions on fetching their content.
This has to stop.
Other widgets might take a role of "controller" widgets (let's say that Display
widget is a good candidate). They should be connected to certain signals of view widgets or provide a content by itself:
class Display(urwid.Columns):
def __init__(self, provider):
provider.get_feeds(self._menu.set_feeds)
provider.get_articles(self._articles.set_articles)
urwid.connect_signal(self._articles, 'navigated', self._art_navigated)
def _art_navigated(self):
if self.maybe_more and self._articles.focus_percentage > 75:
provider.get_articles(self._articles.add_articles, offset=...)