From 979c9252341881d6ef2812740c48501826ca6edd Mon Sep 17 00:00:00 2001 From: Akronymus Date: Tue, 15 Sep 2020 19:45:54 +0200 Subject: [PATCH] Error handling when getch() throws an error Currently untested, but should work well enough. Doing this as an reference implementation. --- menu_screen.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/menu_screen.py b/menu_screen.py index e092af4..116d504 100644 --- a/menu_screen.py +++ b/menu_screen.py @@ -756,10 +756,12 @@ class CursedMenu(object): self.screen.addstr(16, 2, "{}'s garden is locked, but you can see in...".format(guest_garden)) else: self.screen.addstr(16, 2, "i can't seem to find directions to {}...".format(guest_garden)) - self.screen.getch() - self.clear_info_pane() - self.draw_plant_ascii(self.plant) - self.visited_plant = None + try: + self.screen.getch() + self.clear_info_pane() + self.draw_plant_ascii(self.plant) + finally: + self.visited_plant = None def water_on_visit(self, guest_visitor_file): visitor_data = {}