Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change color of text output from the progressbar? #1095

Closed
konradg40 opened this issue Dec 12, 2020 · 2 comments
Closed

How to change color of text output from the progressbar? #1095

konradg40 opened this issue Dec 12, 2020 · 2 comments
Assignees
Labels
duplicate 🗐 Seen it before invalid ⛔ Not-an-issue or upstream (not-our-issue) p2-bug-warning ⚠ Visual output bad submodule-notebook 📓 Much web such IDE

Comments

@konradg40
Copy link

I am using the dark theme in Google Colab which automatically transforms text color from output to white. However, now I am using the progressbar from TQDM module and I get text that is dark colored which is problematic in the dark theme. I was thinking of Colorama but it only changes text color for the text edit (I think?). Here is my code:

import yahoo_fin
from yahoo_fin.stock_info import get_data
bar = trange(72)
bar.write("Downloading data...")
for i,stocks in zip(bar,filtered_list):
df[stocks]= get_data(stocks,stockstart,stockend)['adjclose'].dropna()
bar.write("Completed!")

@casperdcl casperdcl self-assigned this Dec 14, 2020
@casperdcl casperdcl added duplicate 🗐 Seen it before invalid ⛔ Not-an-issue or upstream (not-our-issue) p2-bug-warning ⚠ Visual output bad submodule-notebook 📓 Much web such IDE labels Dec 14, 2020
@casperdcl
Copy link
Sponsor Member

casperdcl commented Dec 14, 2020

see #842... could try updating/reinstalling ipywidgets or reporting it there.

@allrobot
Copy link

allrobot commented May 11, 2024

see #842... could try updating/reinstalling ipywidgets or reporting it there.

How to change color of text output from the progressbar?

colorama seem don't work:

import asyncio
import random
import colorama

from tqdm.asyncio import tqdm_asyncio


class AsyncException(Exception):
    def __int__(self, message):
        super.__init__(self, message)


async def some_coro(simu_exception=False):
    delay = round(random.uniform(1.0, 5.0), 2)

    # We will simulate throwing an exception if simu_exception is True
    if delay > 4 and simu_exception:
        raise AsyncException("something wrong!")

    await asyncio.sleep(delay)

    return delay
async def main():
    tasks = []
    for _ in range(500):
        tasks.append(some_coro())
    print(colorama.Fore.BLUE)
    _ = await tqdm_asyncio.gather(*tasks,ncols=80,desc="Progress",unit="task")

    print(colorama.Fore.RESET)
    print("Use colour to change the color of the bar.")


if __name__ == "__main__":
    asyncio.run(main())

pycharm64_cbtyUZtllS

If I used colour=colorama.Fore.BLUE, but it reports an error:

pycharm64_XqaT4qfAfV

How can I current to change color of text output and no error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate 🗐 Seen it before invalid ⛔ Not-an-issue or upstream (not-our-issue) p2-bug-warning ⚠ Visual output bad submodule-notebook 📓 Much web such IDE
Projects
None yet
Development

No branches or pull requests

3 participants