From 34b5ae35c7c24eeafbee6add4d550ea029f97807 Mon Sep 17 00:00:00 2001 From: Alex Selimov Date: Thu, 16 Nov 2023 23:04:14 -0500 Subject: [PATCH] Add escape as a keybinding to exit screens without saving --- src/tui.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/tui.py b/src/tui.py index 1a3ee2d..d91c896 100644 --- a/src/tui.py +++ b/src/tui.py @@ -48,6 +48,7 @@ class EditTaskScreen(Screen): """ BINDINGS = [ Binding('ctrl+s', 'save', 'Save Changes', priority=True), + Binding('escape', 'exit', 'Exit Without Changes', priority=True), ] def __init__(self,text): """ @@ -82,6 +83,9 @@ class EditTaskScreen(Screen): self.text.description = query.nodes[0].text self.dismiss(self.text) + def action_exit(self): + self.dismiss(None) + class EditColScreen(Screen): """ This is a screen used to edit the name of a task @@ -267,17 +271,19 @@ class KanbanForm(App): task and the board class """ - icol, itask = self.get_col_task() - self.focused.highlighted_child.children[0].update(task.summary) - self.board.update_task(icol, itask, task) + if task: + icol, itask = self.get_col_task() + self.focused.highlighted_child.children[0].update(task.summary) + self.board.update_task(icol, itask, task) def new_task(self, task): """ This function adds a new task to our board """ - icol,_ = self.get_col_task() - self.focused.mount(ListItem(Label(task.summary))) - self.board.add_task(icol, task) - self.focused.highlighted_child + if task: + icol,_ = self.get_col_task() + self.focused.mount(ListItem(Label(task.summary))) + self.board.add_task(icol, task) + self.focused.highlighted_child # def on_key(self): # with open('log','a') as f: