Updated for KeyboardInterrupt

This commit is contained in:
Dimitris Zlatanidis 2023-04-30 22:14:22 +03:00
parent ee06001fad
commit a6091d4c2f
2 changed files with 9 additions and 19 deletions

View file

@ -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)

View file

@ -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__':