From 89822f05aab95ee2e3e590d7bafad9f93a418856 Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Wed, 8 Jun 2022 19:34:31 +0100 Subject: [PATCH] Change formatting in console --- utils/console.py | 7 +++++++ video_creation/voices.py | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/utils/console.py b/utils/console.py index 11ee429..842c60a 100644 --- a/utils/console.py +++ b/utils/console.py @@ -4,6 +4,7 @@ from rich.markdown import Markdown from rich.padding import Padding from rich.panel import Panel from rich.text import Text +from rich.columns import Columns console = Console() @@ -25,3 +26,9 @@ def print_step(text): def print_substep(text, style=""): """Prints a rich info message without the panelling.""" console.print(text, style=style) + + +def print_table(items): + """Prints items in a table.""" + + console.print(Columns([Panel(f"[yellow]{item}", expand=True) for item in items])) diff --git a/video_creation/voices.py b/video_creation/voices.py index 3802b10..11d31d4 100644 --- a/video_creation/voices.py +++ b/video_creation/voices.py @@ -1,9 +1,10 @@ #!/usr/bin/env python3 import os -from utils.console import print_step, print_substep +from utils.console import print_step, print_substep, print_table from tts.engine_wrapper import TTSEngine import tts.google_translate + ## Add your provider here on a new line TTSProviders = {"GoogleTranslate": tts.google_translate} @@ -22,8 +23,7 @@ def save_text_to_mp3(reddit_obj): choice = "" while not chosen: print("Please choose one of the following TTS providers: ") - for i in TTSProviders: - print(i) + print_table(TTSProviders) choice = input("\n") if choice.casefold() not in map(lambda _: _.casefold(), TTSProviders): print("Unknown Choice")