Closed kubaraczkowski closed 4 years ago
Except the "obvious" way of abusing the Counter class and providing/updating the desc
property, with format "{desc}{fill}"
So you're looking for something you can just print to the screen?
Have you tried Counter.format()
? If you set enable=False
to the counter, it won't display the normal progress bar as well.
import time
import enlighten
manager = enlighten.get_manager()
ticks = manager.counter(total=100, desc='Ticks', unit='ticks', enabled=0)
for num in range(100):
time.sleep(0.1)
ticks.update()
if not num % 5:
print(ticks.format())
Or would you need it to have a different format from bar_format
?
Thanks for your example!
Well, indeed, perhaps just using the highly flexible formatting system and slightly abusing the Counter class is all that's needed!
My example below, adding and updating a 'status bar' in addition to a handful of counters.
status_bar_text = f"ver: {__version__}"
status_bar = self.enlighten_manager.counter(
desc=status_bar_text, counter_format="{desc}{fill}"
)
time.sleep(5)
status_bar.desc = "Hello world"
status_bar.refresh()
Oh, are you trying to keep something at the bottom of the screen to let users know some dynamic information? Yeah, you could abuse it that way. I'd have to think if making that easier makes sense or not. I can see how it could.
Right, exactly. In fact I am running sth that spits loads of log information (wow, thanks, the logging integration is great) so I wanted to give also a dynamic text indication of the general status, or, hm, let’s say IP address of the connected server or so.
Making it much easier might be too much of a change, perhaps an example would be enough?
On Tue, 26 May 2020 at 21:32, Avram Lubkin notifications@github.com wrote:
Oh, are you trying to keep something at the bottom of the screen to let users know some dynamic information? Yeah, you could abuse it that way. I'd have to think if making that easier makes sense or not. I can see how it could.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Rockhopper-Technologies/enlighten/issues/20#issuecomment-634231807, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEHNHFTCR2UA3VTQA3VTCLRTQKM3ANCNFSM4NKHXP4A .
I think some status bar class makes sense. In the meantime, do you have what you need to workaround it for now?
Yes, the workaround was fine, thank you.
I looked at the code on how to implement a StatusBar class, but saw it was not immediately obvious without modifying also pieces of the manager, etc. and then decided to contact you.
On Tue, 26 May 2020 at 23:41, Avram Lubkin notifications@github.com wrote:
I think some status bar class makes sense. In the meantime, do you have what you need to workaround it for now?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Rockhopper-Technologies/enlighten/issues/20#issuecomment-634294718, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEHNHFIFR3LLI5T3HYQDATRTQZPJANCNFSM4NKHXP4A .
This has been implemented in 1.6.0. See the documentation for more information.
I'm going to go ahead and close this, but please provide feedback here once you try it out.
Awasome! Great
On Fri, 19 Jun 2020 at 16:10, Avram Lubkin notifications@github.com wrote:
Closed #20 https://github.com/Rockhopper-Technologies/enlighten/issues/20.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Rockhopper-Technologies/enlighten/issues/20#event-3462627796, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEHNHBXTLYSJSUMJLBYEADRXNWUZANCNFSM4NKHXP4A .
Hi,
Great job, this works really well!
One additional idea I have is to be able to add a "generic" status bar line to the output. What could be a good to do that using the current code?
The
Manager
can be used to directlywrite()
to the stream at a given vertical position, but since it's a bypass of the normal update system the output gets overwritten immediately.A
Status
class would be an idea, however the manager is also expecting a single type ofcounter_class
so this won't mix nicely with the default behavior.Thanks!