pyfiglet icon indicating copy to clipboard operation
pyfiglet copied to clipboard

Support for --color on Windows?

Open amitbora007 opened this issue 4 years ago • 7 comments

unable to use '-color','--color' parameter in both CLI and library import method. please provide any usage example

amitbora007 avatar Jan 14 '20 16:01 amitbora007

I'm unsure quite what to make of your issue.

What did you try doing so far, and where did you look to try? It works for me:

Screenshot from 2020-01-17 21-18-46

pwaller avatar Jan 17 '20 21:01 pwaller

I am getting this result with the same command. Is this module specific for some IDE or terminal? I am working on windows using anaconda prompt. image

I also tried the library import method but couldn't found the color option there.

amitbora007 avatar Jan 19 '20 11:01 amitbora007

Ah, I am unfamiliar with the behaviour of pyfiglet on windows, and this is untested, sorry. It looks like windows doesn't use the same representation to control color. I'm afraid I don't know how to fix this and we need to find a willing windows developer to help out.

pwaller avatar Jan 19 '20 11:01 pwaller

Ah, I am unfamiliar with the behaviour of pyfiglet on windows, and this is untested, sorry. It looks like windows doesn't use the same representation to control color. I'm afraid I don't know how to fix this and we need to find a willing windows developer to help out.

okk, thanks for the reply. I will also update if find any fix for this.

amitbora007 avatar Jan 19 '20 11:01 amitbora007

I believe you could do something like that:

   try:
       from colorama import init
       init(strip=not sys.stdout.isatty())
       from termcolor import cprint
   except:
       def cprint(text, color):
          // use default of pyfliglet colors implementation without dependencies

And then adapt the code in pyfiglet to use that. On windows, you would just need to pip install colorama and termcolor to get the color support.

grandemk avatar Jun 05 '20 17:06 grandemk

If possible it would be great to avoid pulling in another dependency.

At time of writing we have ~300 dependent packages and ~6,000 dependent repositories. Adding an extra dependency means affecting all those other packages. Going from 0 to 1 dependency is a significant step and I don't know how to make it whilst being sure not to break backwards compatibility for everyone.

pwaller avatar Nov 01 '20 21:11 pwaller

@amitbora007 it looks like your legacy console doesn't support ANSI sequences. If you have a recent version of Windows you can typically enable it on the console settings panel (menu at top left). Windows terminal might be another option.

Another option is to use colorama, although it isn't necessary any longer to include it as a dependency due to widespread ANSI support.

mixmastamyk avatar Jan 04 '21 04:01 mixmastamyk

Ok to close? Looks resolved to me. (use a different console on windows)

mkinney avatar Apr 07 '23 19:04 mkinney

I'm happy to close this, please comment to request a reopen (with some details as to why) if needed.

pwaller avatar Aug 18 '23 21:08 pwaller