Sorry in advance, I’m a newbie =)
So I’m making a classic program, which is a Passwords Manager program using Python. For now the program is still Text-based using the Rich module as the main display.
I found a problem with the Rich table. That is if the characters of the Service or Password are too long to be displayed on one line, then the service or password will be truncated and display a “…” sign at the end.
(For example as in the picture, don’t mind I use Termux, don’t have a PC :’)).
So is it possible, if the characters are too long to be displayed on one line, it will automatically connect to a new line below and without the “…” sign?
And even if it works, a new problem arises again:
Number, Service/Password, and Added On. Stuck on top, not following to the middle of the line. So the Service/Password extends itself to the bottom, everything else looks empty because it’s stuck at the top.
Sorry if it’s too long =) and thanks!
My Code:
def view_passwords(key):
"""View stored passwords in a formatted table."""
passwords = load_passwords(key)
if passwords:
table = Table(title="Your Stored Passwords :memo:", title_style="bold magenta")
table.add_column("No.", style="cyan", justify="center")
table.add_column("Service", style="cyan", justify="center")
table.add_column("Password", style="magenta", justify="center")
table.add_column("Added On", style="green", justify="center")
for i, (service, encrypted_data) in enumerate(passwords.items(), 1):
decrypted_data = decrypt_data(encrypted_data, key)
if decrypted_data:
decrypted_string = decrypted_data.decode('utf-8')
data = json.loads(decrypted_string)
password = data.get("password")
timestamp = data.get("timestamp")
table.add_row(str(i), service, password, timestamp)
console.print(table, justify="center")
pause_and_space()
else:
console.print(Panel(
"[bold red]You have no stored passwords. :crying_face:[/]",
title="[bold red]No Passwords Found",
title_align="center",
padding=(1, 2),
border_style="red"
), justify="center")
pause_and_space()