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