Created
March 15, 2016 23:04
-
-
Save mekhami/987cfec89d767e64ea07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urwid | |
| def on_exit_clicked(button): | |
| raise urwid.ExitMainLoop() | |
| def exit_on_q(key): | |
| if key.upper() == 'Q': | |
| raise urwid.ExitMainLoop() | |
| def task_question(): | |
| return urwid.Edit(u"What is your task?\n") | |
| def pomo_question(): | |
| return urwid.Edit(u"How many pomodoros for this task?\n") | |
| def timer(): | |
| return urwid.Pile([urwid.Text(u"Timer will go here.")]) | |
| class QuestionBox(urwid.ListBox): | |
| def __init__(self): | |
| body = urwid.SimpleFocusListWalker([task_question()]) | |
| super().__init__(body) | |
| def keypress(self, size, key): | |
| key = super().keypress(size, key) | |
| if key != 'enter': | |
| return key | |
| task = self.focus.edit_text | |
| if not task: | |
| raise urwid.ExitMainLoop() | |
| self.focus.contents = pomo_question() | |
| pomos = self.focus.edit_text | |
| if not pomos: | |
| raise urwid.ExitMainLoop() | |
| pos = self.focus_position | |
| self.body.insert(pos + 1, timer()) | |
| self.focus_position = pos + 1 | |
| #button = urwid.Button(u'Exit') | |
| #urwid.connect_signal(button, 'click', on_exit_clicked) | |
| loop = urwid.MainLoop(QuestionBox()) | |
| loop.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment