Sujet : Re: How to Add ANSI Color to User Response
De : bouncingcats (at) *nospam* gmail.com (David)
Groupes : comp.lang.pythonDate : 11. Apr 2024, 03:24:59
Autres entêtes
Message-ID : <mailman.92.1712802339.3468.python-list@python.org>
References : 1 2
On Wed, 10 Apr 2024 at 18:51, WordWeaver Evangelist via Python-list
<
python-list@python.org> wrote:
I have a simple question. I use the following textPrompt in some of my
Jython modules:
'\n [1;33mYour choice is? (A B C D E): ', maxChars=1, autoAccept=False, forceUppercase=True)
Is there a way to add an ANSI color code to the end where the conditions
are, so that the color of the user’s input is of a color of my choosing,
instead of just white?
Hi Bill,
Here's a tutorial:
https://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.htmlNote the sentence: "once you print out the special code enabling a color,
the color persists forever until someone else prints out the code for
a different color, or prints out the Reset code to disable it."
Here's a more detailed specification:
https://en.wikipedia.org/wiki/ANSI_escape_codeAnd here's a conversation:
http://mywiki.wooledge.org/BashFAQ/037(see the first sentence, and then under the heading "Discussion")
that might help you decide whether this approach will satisy your need in
your particular circumstances of operating system, Python version, and
terminal settings.