Change formatting in console

pull/432/head
Callum Leslie 3 years ago
parent 9b615a5971
commit 89822f05aa

@ -4,6 +4,7 @@ from rich.markdown import Markdown
from rich.padding import Padding from rich.padding import Padding
from rich.panel import Panel from rich.panel import Panel
from rich.text import Text from rich.text import Text
from rich.columns import Columns
console = Console() console = Console()
@ -25,3 +26,9 @@ def print_step(text):
def print_substep(text, style=""): def print_substep(text, style=""):
"""Prints a rich info message without the panelling.""" """Prints a rich info message without the panelling."""
console.print(text, style=style) 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]))

@ -1,9 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os 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 from tts.engine_wrapper import TTSEngine
import tts.google_translate import tts.google_translate
## Add your provider here on a new line ## Add your provider here on a new line
TTSProviders = {"GoogleTranslate": tts.google_translate} TTSProviders = {"GoogleTranslate": tts.google_translate}
@ -22,8 +23,7 @@ def save_text_to_mp3(reddit_obj):
choice = "" choice = ""
while not chosen: while not chosen:
print("Please choose one of the following TTS providers: ") print("Please choose one of the following TTS providers: ")
for i in TTSProviders: print_table(TTSProviders)
print(i)
choice = input("\n") choice = input("\n")
if choice.casefold() not in map(lambda _: _.casefold(), TTSProviders): if choice.casefold() not in map(lambda _: _.casefold(), TTSProviders):
print("Unknown Choice") print("Unknown Choice")

Loading…
Cancel
Save