Closed Dauriel closed 1 year ago
It's not documented specifically, but you can change the color attribute for the counter. It does the same validation for the color that's done when you originally set it. Will you change the color once or twice or many times during the program's runtime?
import time
import enlighten
counter = enlighten.Counter(total=100, desc='Example', unit='ticks', color='red')
for num in range(100):
time.sleep(0.05) # Simulate work
if num == 50:
counter.color = 'blue'
counter.update()
Oh sweet! Thanks for the quick reply.
I do plan on changing the color many times during the runtime. Do you think that could constitute an issue?
There's a small overhead in validating the color. I don't think you'll notice it, but I could probably move it to it's own method and make it caching so it can be skipped, but I wouldn't worry about it for now.
Hm ye that might be a problem. I'd be changing color quite a bit. I'll run some tests and then decide, thanks!
Is your feature request related to a problem? Please describe. Would be nice to have a color input in the update function of the status bar to change the color dynamically.
Describe alternatives you've considered Recreating the color bar instead of updating it does the trick, yet it seems impractical.
Additional context I am not sure if this is already possible or if there's a workaround. I also have not seen it anywhere in the documentation. Sorry if I missed it.