You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i am trying to print number of tables that fits the screen. I dont want them to flicker or scroll, while printing. i made an attempt with prettytables and then with rich (code not yet completed fully). As you can see Rich, code is little more complicated or I am using it in a wrong way. I can see rich scrolls while prettytables flicker.
def richest(**kwargs):
def generate_table(dct) -> Table:
table = Table()
for key in dct:
table.add_column(key)
row_values = tuple()
for key, value in dct.items():
if isinstance(value, (int, float)) and value > 0:
color = "[green]"
elif isinstance(value, (int, float)):
color = "[red]"
else:
color = "[blue]"
colored = f"{color}{value}"
row_values += (colored,)
table.add_row(*row_values)
print(table)
for k, v in kwargs.items():
if isinstance(v, dict):
with Live(generate_table(v), refresh_per_second=1):
pass
return kwargs
def prettier(**kwargs) -> dict:
for k, v in kwargs.items():
table = PrettyTable()
if isinstance(v, dict):
table.field_names = v.keys()
table.add_row(v.values())
print(table)
elif isinstance(v, list):
table.field_names = v[0].keys()
for item in v:
table.add_row(item.values())
print(table)
else:
print(k, ":", Regative(v))
print(25 * "=", " END OF REPORT ", 25 * "=", "\n")
return kwargs
i doubt if i am using rich library wrong. I hope i am clear in my requirements that I want only the screen update the changing values on each iteration (or so it appears to the eyes, minus he flicker).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
i am trying to print number of tables that fits the screen. I dont want them to flicker or scroll, while printing. i made an attempt with prettytables and then with rich (code not yet completed fully). As you can see Rich, code is little more complicated or I am using it in a wrong way. I can see rich scrolls while prettytables flicker.
i doubt if i am using rich library wrong. I hope i am clear in my requirements that I want only the screen update the changing values on each iteration (or so it appears to the eyes, minus he flicker).
rich
prettytables
Please help.
Beta Was this translation helpful? Give feedback.
All reactions