From a6091d4c2ffeedaf7b4cb41ce191f5d773e6252a Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 30 Apr 2023 22:14:22 +0300 Subject: [PATCH] Updated for KeyboardInterrupt --- slpkg/dialog_box.py | 26 +++++++------------------- slpkg/main.py | 2 ++ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/slpkg/dialog_box.py b/slpkg/dialog_box.py index 086bab77..977140e5 100644 --- a/slpkg/dialog_box.py +++ b/slpkg/dialog_box.py @@ -29,11 +29,8 @@ class DialogBox(Configs): if self.dialog: more_kwargs.update({"item_help": True}) - try: - code, tags = self.d.checklist(text=text, choices=choices, title=title, height=height, width=width, - list_height=list_height, help_status=True, **more_kwargs) - except KeyboardInterrupt: - raise SystemExit() + code, tags = self.d.checklist(text=text, choices=choices, title=title, height=height, width=width, + list_height=list_height, help_status=True, **more_kwargs) else: code: bool = False @@ -48,12 +45,9 @@ class DialogBox(Configs): if self.dialog: more_kwargs.update({"item_help": True, "help_tags": True}) - try: - code, tags = self.d.mixedform(text=text, title=title, elements=elements, # type: ignore - height=height, width=width, help_button=True, - help_status=True, **more_kwargs) - except KeyboardInterrupt: - raise SystemExit() + code, tags = self.d.mixedform(text=text, title=title, elements=elements, # type: ignore + height=height, width=width, help_button=True, + help_status=True, **more_kwargs) else: code: bool = False tags: list = elements @@ -63,15 +57,9 @@ class DialogBox(Configs): def msgbox(self, text: str, height: int, width: int) -> None: """ Display a message box. """ if self.dialog: - try: - self.d.msgbox(text, height, width) - except KeyboardInterrupt: - raise SystemExit() + self.d.msgbox(text, height, width) def textbox(self, text: Union[str, Path], height: int, width: int) -> None: """ Display a text box. """ if self.dialog: - try: - self.d.textbox(text, height, width) - except KeyboardInterrupt: - raise SystemExit() + self.d.textbox(text, height, width) diff --git a/slpkg/main.py b/slpkg/main.py index 6c87a69d..b5a64384 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -834,6 +834,8 @@ def main() -> None: logger = logging.getLogger(LoggingConfig.date) logger.exception(main.__name__) usage.help_short(1) + except KeyboardInterrupt: + raise SystemExit(1) if __name__ == '__main__':