Add a generic Progressbar which allows printing additional objects

This commit is contained in:
Matthias
2024-07-07 16:13:55 +02:00
parent 69628736b2
commit befefd449c
2 changed files with 14 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ from freqtrade.util.formatters import decimals_per_coin, fmt_coin, round_value
from freqtrade.util.ft_precise import FtPrecise
from freqtrade.util.measure_time import MeasureTime
from freqtrade.util.periodic_cache import PeriodicCache
from freqtrade.util.rich_progress import CustomProgress
from freqtrade.util.rich_tables import print_df_rich_table, print_rich_table
from freqtrade.util.template_renderer import render_template, render_template_with_fallback # noqa
@@ -39,4 +40,5 @@ __all__ = [
"MeasureTime",
"print_rich_table",
"print_df_rich_table",
"CustomProgress",
]

View File

@@ -0,0 +1,12 @@
from rich.console import ConsoleRenderable, Group, RichCast
from rich.progress import Progress
class CustomProgress(Progress):
def __init__(self, *args, cust_objs, **kwargs) -> None:
self._cust_objs = cust_objs
super().__init__(*args, **kwargs)
def get_renderable(self) -> ConsoleRenderable | RichCast | str:
renderable = Group(*self._cust_objs, *self.get_renderables())
return renderable