[BUG] Flashing Progress Bars (Colorama?)
See original GitHub issueDescribe the bug
When I utilize functions/classes within the pyNastran
library, my progress bars start flashing and lose the bar color. pyNastran
seems to use a custom logger written by @SteveDoyle2, which uses Colorama. I suspect thereโs some clash with the built-in logging from PyNastran, and the colors my own code uses from Rich.
To Reproduce From the docs and slightly expanded:
from rich.progress import track
import time
for n in track(range(20), description="Processing..."):
time.sleep(0.5)
Now with just a BDF object from the pyNastran library instantiated, do exactly the same thing:
from rich.progress import track
import time
from pyNastran.bdf.bdf import BDF
_ = BDF()
for n in track(range(20), description="Processing..."):
time.sleep(0.25)
Color goes away until itโs completed, and with more complex progress trackers the spinners/time columns seem to flash.
Platform What platform (Win/Linux/Mac) are you running on? What terminal software are you using?
Windows 10. Windows Terminal (calling cmd.exe). Python 3.8.5. Rich 10.1.0
Diagnose
python -m rich.diagnose
python -m rich._windows
pip freeze | grep rich
โญโโโโโโโโโโโโโโโโโโโโโโโโโ <class 'rich.console.Console'> โโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ A high level console interface. โ
โ โ
โ โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ โ <console width=132 ColorSystem.TRUECOLOR> โ โ
โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ โ
โ color_system = 'truecolor' โ
โ encoding = 'utf-8' โ
โ file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> โ
โ height = 61 โ
โ is_alt_screen = False โ
โ is_dumb_terminal = False โ
โ is_interactive = True โ
โ is_jupyter = False โ
โ is_terminal = True โ
โ legacy_windows = False โ
โ no_color = False โ
โ options = ConsoleOptions( โ
โ size=ConsoleDimensions(width=132, height=61), โ
โ legacy_windows=False, โ
โ min_width=1, โ
โ max_width=132, โ
โ is_terminal=True, โ
โ encoding='utf-8', โ
โ justify=None, โ
โ overflow=None, โ
โ no_wrap=False, โ
โ highlight=None, โ
โ markup=None, โ
โ height=None โ
โ ) โ
โ quiet = False โ
โ record = False โ
โ safe_box = True โ
โ size = ConsoleDimensions(width=132, height=61) โ
โ soft_wrap = False โ
โ stderr = False โ
โ style = None โ
โ tab_size = 8 โ
โ width = 132 โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
platform="Windows"
WindowsConsoleFeatures(vt=True, truecolor=True)
(I donโt have grep or cygWin/gitBash installed at all)
'grep' is not recognized as an internal or external command,
operable program or batch file.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
@willmcgugan That seems to fix it!
Conclusion: If any code or imported libraries use Colorama, it can cause graphical glitches with colors, spinners, and progress bars. If you know you have this โconflictโ add the following to your imports section:
Thanks so much Will and Steven for your help here! Iโll close this issue.
Iโve never tried rich outside of my quick test today, so Iโm not sure how rich is supposed to look, but I think itโs due to the difference in how we call colorinit. I use autoreset=True in cpylog (imported by pyNastran) and rich uses strip=False and theyโre both called.
The behavior under powershell seems strange (the line changing after itโs done), but thatโs consistently weird. Terminal changes the color of the line during runtime based on the init flags.
Thereโs probably an update init call that needs to be done, that probably should be handled externally from either package.