Make ATM a single scroll list
This commit is contained in:
@@ -8,43 +8,40 @@ class TaskList(object):
|
|||||||
self.grid = urwid.Frame(
|
self.grid = urwid.Frame(
|
||||||
urwid.ListBox(
|
urwid.ListBox(
|
||||||
urwid.SimpleFocusListWalker(
|
urwid.SimpleFocusListWalker(
|
||||||
[TaskRow(t, self.on_task_clicked) for t in tasks]
|
[TaskRow(t, self.callback) for t in tasks]
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
header=urwid.Text(header),
|
header=urwid.Text(('header', header)),
|
||||||
focus_part='body'
|
focus_part='body'
|
||||||
)
|
)
|
||||||
|
|
||||||
def on_task_clicked(self, id):
|
|
||||||
self.callback(id)
|
|
||||||
|
|
||||||
def component(self):
|
def component(self):
|
||||||
return self.grid
|
return self.grid
|
||||||
|
|
||||||
class MyTasks(object):
|
class MyTasks(object):
|
||||||
def __init__(self, tasks, on_task_click):
|
def __init__(self, tasks, on_task_click):
|
||||||
|
self.callback = on_task_click
|
||||||
all_tasks = [t for t in tasks]
|
all_tasks = [t for t in tasks]
|
||||||
|
|
||||||
today = [t for t in all_tasks if t.atm_section() == 'today']
|
self.new = [t for t in all_tasks if t.atm_section() == 'inbox']
|
||||||
upcoming = [t for t in all_tasks if t.atm_section() == 'upcoming']
|
self.today = [t for t in all_tasks if t.atm_section() == 'today']
|
||||||
later = [t for t in all_tasks if t.atm_section() == 'later']
|
self.upcoming = [t for t in all_tasks if t.atm_section() == 'upcoming']
|
||||||
|
self.later = [t for t in all_tasks if t.atm_section() == 'later']
|
||||||
self.today_grid = TaskList(today,
|
|
||||||
('atm_section', 'Today'),
|
|
||||||
on_task_click)
|
|
||||||
self.upcoming_grid = TaskList(upcoming,
|
|
||||||
('atm_section', 'Upcoming'),
|
|
||||||
on_task_click)
|
|
||||||
self.later_grid = TaskList(later,
|
|
||||||
('atm_section', 'Later'),
|
|
||||||
on_task_click)
|
|
||||||
|
|
||||||
def component(self):
|
def component(self):
|
||||||
return urwid.Frame(urwid.Pile([
|
return urwid.Frame(
|
||||||
self.today_grid.component(),
|
urwid.ListBox(
|
||||||
self.upcoming_grid.component(),
|
urwid.SimpleFocusListWalker([
|
||||||
self.later_grid.component()
|
urwid.Text(('atm_section', 'New'))
|
||||||
]),
|
] + [TaskRow(t, self.callback) for t in self.new] + [
|
||||||
|
urwid.Text(('atm_section', 'Today'))
|
||||||
|
] + [TaskRow(t, self.callback) for t in self.today] + [
|
||||||
|
urwid.Text(('atm_section', 'Upcoming'))
|
||||||
|
] + [TaskRow(t, self.callback) for t in self.upcoming] + [
|
||||||
|
urwid.Text(('atm_section', 'Upcoming'))
|
||||||
|
] + [TaskRow(t, self.callback) for t in self.later]
|
||||||
|
)
|
||||||
|
),
|
||||||
header=urwid.Text(('header', 'My Tasks')),
|
header=urwid.Text(('header', 'My Tasks')),
|
||||||
focus_part='body'
|
focus_part='body'
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user