Closed Advik-B closed 1 year ago
Why not? I made it that way so it could be always correctly initialized and finalized, there isn't much sense trying to not use it.
Cause of this
Ok, you'd do it like this:
class ProgressBar:
def __init__(self, value: int = None):
self.cm = alive_bar(total=value)
self.bar = self.cm.__enter__()
def step(self):
self.bar()
def close(self):
self.cm.__exit__(None, None, None)
To use it:
progress = ProgressBar(1000)
for i in range(1000):
time.sleep(.01)
progress.step()
progress.close()
Thank you will. Try this. Please keep the issue open
Ok, but how do I access the usefull variables like:
bar.total
bar.current
self.bar
field is the exact alive_progress' bar
, so you can use anything that I provide there.
There isn't the total for example, but you should know with which you started, so you could do:
class ProgressBar:
def __init__(self, value: int = None):
self._total = total
self.cm = alive_bar(total=value)
self.bar = self.cm.__enter__()
def step(self):
self.bar()
def close(self):
self.cm.__exit__(None, None, None)
@property
def total(self):
return self._total
@property
def current(self):
return self.bar.current()
Okay, will try this
Ok, I'm closing this one, but feel free to reply here if you need any more help 👍
I dont want to use the
with
context manager