Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
colouring strings
#11
newbieAuggie2019 Wrote:because I tried your suggestion (term.py) and others from the cmder site, and I'm not sure I have done it right:
I did post this,so term.py is just name i used for your code that i run in cmder
(Sep-17-2019, 04:23 PM)snippsat Wrote: Test term.py is your latest code.
# term.py
import sys
from termcolor import colored, cprint
 
text = colored('Hello, World!', 'red', attrs=['reverse', 'blink'])
print(text)
cprint('Hello, World!', 'green', 'on_red')
 
print_red_on_cyan = lambda x: cprint(x, 'red', 'on_cyan')
print_red_on_cyan('Hello, World!')
print_red_on_cyan('Hello, Universe!')
 
for i in range(10):
    cprint(i, 'magenta', end=' ')
 
cprint("Attention!", 'red', attrs=['bold'], file=sys.stderr)
newbieAuggie2019 Wrote:I always have problems with path
Windows Path most work,means that python and pip command most work form any folder.
C:\code
λ python -V
Python 3.7.2

C:\code
λ pip -V
pip 19.2.3 from c:\python37\lib\site-packages\pip (python 3.7)
If don't work fix it,all info needed is here Python 3.6/3.7 and pip installation under Windows.
Reply
#12
I didn't change the links. :)
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#13
Here it is. Windows 10 Command Prompt:

https://prnt.sc/p7pc9d
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#14
(Sep-17-2019, 10:11 PM)snippsat Wrote: I did post this,so term.py is just name i used for your code that i run in cmder
[quote="snippsat" pid="91773" dateline="1568737421"]Test term.py is your latest code.
Wall I'm so thick ... I'm so thick ... I'm so thick ... I'm so thick ... I'm so thick ... I'm so thick ... I'm so thick ... I'm so thick ...

I don't know why, but I thought term.py was some kind of test program, not the code I had attached!!!

I don't know what I was doing or where I was doing it, because as I had posted previously, the pip installation for colorama and for termcolor was successful on both cases. Finally, I have managed to make both of them work, but they don't fulfill my expectations ... Cry

I wanted something like here, with the so-called HTML-like tags, very straightforward and easy.

Incidentally, I've been learning many little pieces of many things through my investigation, but still I don't think I've found yet what I wanted.

Let's compare, for instance, the code we need to show something here in a post. We can modify the font, its size, colour or appearance, like bold, italic, or underline. If we want a word underlined, we just surround that word with the pair of tags [*u][*/u] (I just added the asterisks inside the tags to make the tags visible, as otherwise, we would see the characteristics applied, but not the tags), no need to even use the word 'underline', the same goes with bold [*b][*/b], or italic [*i][*/i]. Okay, so, if I wanted a string like 'I like python-forum... a lot!' with a bit of formatting like 'I like python-forum... a lot!', I just have to put 'python-forum' in the center of these paired-tags: [*color=#1ABC9C][*u][*b][*/b][*/u][*/color], and 'a lot!' surrounded by the pair of tags [*i][*/i]. What's more, I didn't even have to write those tags, but instead, I selected the piece of string that I wanted to be changed in style Dance and then clicked on the options on the top of the reply box. That easy!!! Clap
Well, that's oversimplifying the issue, as I guessed there must be a lot of code behind it, but once you run it, you just have to go to the reply box, write what you want and select the strings you want to be formatted, apply the characteristics you want, by just clicking on the icons of your desired characteristics and then, by clicking on the Post Reply button, you can see your strings formatted, once and again!
If I want that same little sentence formatted with one of the programs available for Python, it would require a bit more effort.

λ python -V
Python 3.7.2

λ pip -V
pip 19.2.3 from c:\python37\lib\site-packages\pip (python 3.7)
Thanks, nice tips to check versions!

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply
#15
(Sep-18-2019, 08:25 AM)wavic Wrote: I didn't change the links. :)
Oh, dear! I must have gone completely bonkers by now ... Sad Big Grin Bonkself

(Sep-18-2019, 11:10 AM)wavic Wrote: Here it is. Windows 10 Command Prompt:

https://prnt.sc/p7pc9d
Thanks again!

Finally, I managed to do it too!
[Image: Finally-I-did-it-too.png]
By the way, I tried to use f-strings in the following little program (in the end, I commented those two lines out after so many trials and errors: invalid syntax, can't assign to literal ... ). The program works, but I wanted to apply f-strings to the coding. What am I doing wrong?:
# strings_compared_EXTRA_01.py
#

import sys
from termcolor import colored, cprint

# str1 = "dangerous", "RED", attrs=["bold", "underline"]
# cprint(f'\nThis is  {str1} ... for my mental health!\n\n')

cprint('\nThis is ', end='')
cprint('dangerous', 'green', attrs=['bold', 'underline'], end='')
cprint('... for my mental health!', end='\n\n')
It works, but I wanted to make it better:
[Image: dangerous.png]
I've been trying to work with more complex strings, like quotations:
# compare_complex_strings_04_for_cmder_FINAL.py
#

import sys
from termcolor import colored, cprint

name = "\u001b[33;1m\u001b[46;1m\u001b[1mAlbert Einstein\u001b[0m"
age = 76
quote1 = '\u001b[44;1m\u001b[1m\u001b[1m\u201cImagination is more important than knowledge.   \n\
Knowledge is limited.                            \n\
Imagination encircles the world.\u201d                \u001b[0m'
quote2 = '\u001b[44;1m\u001b[1m\u001b[1m\u201cTry not to become a man of success,             \n\
but rather try to become a man of value.\u201d        \u001b[0m'
quote3 = '\u001b[44;1m\u001b[1m\u001b[1m\u201cThe important thing is to not stop questioning. \n\
Curiosity has its own reason for existing.\u201d      \u001b[0m'


print("\n\n\u001b[4m\u001b[35;1mThis is printing strings with f-formatting:\u001b[0m")
print(f"""
{name} \u001b[32;1mwas a very famous scientist of the 20th century.
He was {age} when he died in 1955.

Many quotes have been attributed to him, for instance:\u001b[0m

{quote1}

\u001b[32;1mThis one also:\u001b[0m

{quote2}

\u001b[32;1mAnd even this one:\u001b[0m

{quote3}
""")
producing the following output:
[Image: complex-quotations-01.png]

Even with Chinese characters and the pronunciation indicated in pinyin:
# compare_complex_strings_03_for_cmder_FINAL.py
#


import timeit
import datetime
import sys
from termcolor import colored, cprint

name = "\u001b[33;1m\u001b[46;1m\u001b[1mJackie Chan\u001b[0m"
age = 65
famous_Chinese_proverb = "\u001b[44;1m\u001b[1m\u001b[1m\u201cA journey of a thousand miles begins with a single step.\u201d \n"
Chinese = "\u001b[44;1m\u001b[1m\u001b[1m(Chinese: 千里之行,始於足下).                             \u001b[0m\n\
                     "
pinyin = "\u001b[44;1m\u001b[1m\u001b[1m(pinyin: Qiānlǐ zhī xíng, shǐyú zú xià).                   \u001b[0m\n\
                                             "
literally = "\u001b[44;1m\u001b[1m\u001b[1m(literally: \u201cA journey of a thousand Chinese               \n\
miles (li) starts beneath one\'s feet\u201d).                    \u001b[0m\n"
birthday_str = '1954/04/07' # Birthday: 7 of April, 1954.
year, month, day = (int(x) for x in birthday_str.split('/'))
ans = datetime.date(year, month, day)
birthday = ans.strftime("%A %d of %B, %Y")

print("\n\n\u001b[4m\u001b[35;1mThis is printing strings with f-formatting:\u001b[0m")
print(f"""
\u001b[32;1mA famous Chinese proverb says:\u001b[0m\n\n\
{famous_Chinese_proverb}
{Chinese}
{pinyin}                  
{literally}\u001b[0m\n 

{name}\u001b[32;1m is a well-known Chinese actor.
Next year he is {age+1} years old.\n 
He was born on {birthday}.\u001b[0m
""")
producing the following output:
[Image: complex-quotations-02.png]
Well, I find it too bothersome for what I think it's not a complicated output, and the attribute of 'italic' seems to be impossible in a computer running on a Windows operating system.

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply
#16
Hi again!

I’ve been trying to find an easy and straightforward way to manipulate strings, giving them colour, and/or applying characteristics like different types of fonts, size, with bold, underline, italic and blinking attributes, among others.

I have spent a lot of time looking for possibilities and choices for Python 3, then downloading them, studying their documentation, making little programs to verify their claims, and finally getting frustrated for not meeting my expectations or even in some cases their own claims.

If you had wished also to work with colours and styles, maybe the information I’m going to share here might help you to choose one or another of the packages. Nevertheless, please keep in mind that it is my personal opinion and that it can be different from yours.

I’m going to compare 5 of these options, and show you the output with these options in my computer running on Windows 10. Why do I explicitly say that my computer runs on Windows 10?

Well, because it seems that that is the reason why these programs don’t behave like they should. I’ve seen images and read comments from users with computers running on Linux, Ubuntu and the like, that show these programs behaving like they should.

I wonder why it seems that Microsoft doesn’t seem to provide a solution for this problem that it appears to be related to how ANSI escape character sequences (for producing coloured terminal text and cursor positioning) are handled by the computer. These ANSI escape characters don't work in Windows. They will work on ANSI consoles like Linux shells, but not in Windows. Windows has their own escape characters. It makes you think that there is no wonder that many users change the Microsoft owned Windows operating system (OS) of their computers, for others like Linux or Ubuntu (even if it might be not only for this). As I have read in some places, this issue is not new and it has been around for more than five years. You could say that in that time and with all the millions of dollars that Microsoft has earned through these years, they could have put a team to sort this out. Well, if they have … it doesn’t say much about their competence if in five years , we keep on having the same problem not solved yet …

I’m going to provide here some data and comments about five packages, that I have been testing and working with Python 3.7.4 for a colourful output, on a bit deeper level than others that I’ll mention later on. First, the essentials:

colorama 0.4.1
https://pypi.org/project/colorama/
information on site: Cross-platform coloured terminal text.
Last release: ‎Nov‎ ‎25‎, ‎2018.

Termcolor 1.1.0
https://pypi.org/project/termcolor/
information on site: ANSII Color formatting for output in terminal.
Last release: ‎Jan‎ ‎13‎, ‎2011.

prompt_toolkit 2.0.9
https://pypi.org/project/prompt_toolkit/
information on site: Library for building powerful interactive command lines in Python.
Last release: ‎Feb‎ ‎19‎, ‎2019.

sty 1.0.0b12
https://pypi.org/project/sty/
information on site: Simple, flexible and extensible string styling for your terminal.
Last release: ‎Sep‎ ‎10‎, ‎2019.

colorful 0.5.4
https://pypi.org/project/colorful/
information on site: Terminal string styling done right, in Python.
Last release: ‎Sep‎ ‎21‎, ‎2019.

And now some comments on them:

colorama 0.4.1
https://pypi.org/project/colorama/
information on site: Cross-platform coloured terminal text.
Last release: ‎Nov‎ ‎25‎, ‎2018.

It seems to be one of the most popular packages around.

According to the site, it makes ANSI escape character sequences (for producing coloured terminal text and cursor positioning) work under MS Windows. ANSI escape character sequences have long been used to produce coloured terminal text and cursor positioning on Unix and Macs. Colorama makes this work on Windows, too.

I thought this was the solution to my problems, as it seemed that there was a lot of information about it and everyone was mentioning colorama when speaking of a way to give colour and attributes to strings. Unfortunately, I was saddened when I read an answer from Jonathan Hartley (Tartley), the author of the project, to a user asking if colorama had italic style:

“It is my opinion that Colorama shouldn't try to (badly) duplicate all the functionality that is already available very thoroughly and elegantly in packages like termcolor or the amazing blessings. To be honest, I regret including all of the colours and styles that are already built into colorama [ … ] I wish we could just do one thing (Windows compatibility) and do it well.”

and even more disheartening when he followed up saying:

“I consider myself retired from the project.”

I think it’s a pity, although he left other contributors in charge of the project.
https://github.com/tartley/colorama/issues/122

Termcolor 1.1.0
https://pypi.org/project/termcolor/
information on site: ANSII Color formatting for output in terminal.
Last release: ‎Jan‎ ‎13‎, ‎2011.

It seems to be also, one of the most popular packages around.
It is even praised by Jonathan Hartley (Tartley), the author of colorama. (The last release of termcolor was almost eight years prior to the last release of colorama).
I think it has similar capabilities to the other 4 packages in the group of 5 that I’m testing.

prompt_toolkit 2.0.9
https://pypi.org/project/prompt_toolkit/
information on site: Library for building powerful interactive command lines in Python.
Last release: ‎Feb‎ ‎19‎, ‎2019.

On the description, there were some parts that caught my eye: Runs on all Python versions from 2.6 up to 3.7. Works well with Unicode double width characters (Chinese input). Runs on Linux, OS X, FreeBSD, OpenBSD and Windows systems. The last release was 7 months ago.

I also like the fact that it can be used with HTML-like tags. So we can use instructions like these:
print_formatted_text(HTML('<b>This is bold</b>')) 
print_formatted_text(HTML('<i>This is italic</i>')) 
print_formatted_text(HTML('<u>This is underlined</u>'))
sty 1.0.0b12
https://pypi.org/project/sty/
information on site: Simple, flexible and extensible string styling for your terminal.
Last release: ‎Sep‎ ‎10‎, ‎2019.

One of my last candidates that I had set my hopes on, as its last release was just twelve days ago, so I thought that some problems would have been fixed by now, even more when on the description, they said that recent versions of Windows 10 should work with this package as well.

colorful 0.5.4
https://pypi.org/project/colorful/
information on site: Terminal string styling done right, in Python.
Last release: ‎Sep‎ ‎21‎, ‎2019.

This is just my last candidate (the original comparison was with only the four previous ones, but as I keep going on in my search for the Holy Grail, I saw this one, whose last release was YESTERDAY!!!).

Well, now I’ll show a small program adapted to each of these 5 packages to print a formatted string, using the attributes for bold, underline, italic and colour and then the output image, using Cmder as the output terminal, because if I use the Python 3.7.4 Shell, we’d only see a bunch of numbers, slashes and square brackets, beside a not colourful nor formatted text.

First, for colorama (I’ve tried to apply the f-string formatting on all the five packages):

# strings_compared_01_BIS_FINAL.py
#

import colorama
from colorama import init
init()
from colorama import Fore, Back, Style

print(f'\nI like {Style.BRIGHT}{Fore.GREEN}python-forum{Style.RESET_ALL} ... a lot!')

# MY COMMENTS:
#
# 1) The author of colorama called properly 'BRIGHT' to what others called
# 'bold'; that is to say, it shows as a bit bright, but not 'bold'. 
#  
# 2) Colorama only has the following Styles (in other programs called
# attributes): DIM, NORMAL, BRIGHT, RESET_ALL. Actually, NORMAL and RESET_ALL
# do not do the same, because while NORMAL would change everything but the
# colour, RESET_ALL will put back to normal, all the previous settings,
# including the colour. DIM and BRIGHT are hardly perceptible. 
#
# 3) COLORAMA HAS NO 'ITALIC' or 'UNDERLINE' attributes (Styles in colorama).
#
# 4) For what I've found, it seems that the reason for 'bold', 'italic'
# and other characteristics not working, is due to the computer running
# on a Microsoft Windows Operating System (OS), as it seems that when
# it's running on Ubuntu or similar, there is not such a problem!!!
Second, for termcolor (I’ve tried to apply the f-string formatting on all the five packages, but I couldn’t manage it with termcolor):

# strings_compared_02_BIS_FINAL.py
#

import sys
from termcolor import colored, cprint

cprint('\nI like ', end='')
cprint('python-forum', 'green', attrs=['bold', 'underline'], end='')
cprint(' ... a lot!', end='\n')

# MY COMMENTS:
#
# 1) The attribute 'bold' doesn't seem to work. Actually, it seems 
# to be maybe a bit brighter, but not 'bold'. 
#  
# 2) I had to eliminate  attrs=['italic'], because 'termcolor' has 
# no attribute for 'italic'.
#
# 3) The 'underline' works. HOORAY!
#
# 4) For what I've found, it seems that the reason for 'bold', 'italic'
# and other characteristics not working, is due to the computer running
# on a Microsoft Windows Operating System (OS), as it seems that when
# it's running on Ubuntu or similar, there is not such a problem!!!
Third, for prompt_toolkit:

# strings_compared_03_BIS_FINAL.py
#

from __future__ import unicode_literals, print_function
from prompt_toolkit import print_formatted_text, HTML

print_formatted_text(HTML(f'\nI like <ansigreen><b><u>python-forum</u></b></ansigreen><i> ... a lot!</i>'))

# MY COMMENTS:
#
# 1) The attribute 'bold' doesn't seem to work. Actually, it seems 
# to be maybe a bit brighter, but not 'bold'. 
#  
# 2) Although 'prompt_toolkit' has the attribute 'italic', it doesn't
# seem to work here.
#
# 3) The 'underline' works. HOORAY!
#
# 4) For what I've found, it seems that the reason for 'bold', 'italic'
# and other characteristics not working, is due to the computer running
# on a Microsoft Windows Operating System (OS), as it seems that when
# it's running on Ubuntu or similar, there is not such a problem!!!
Fourth, for sty (I’ve tried to apply the f-string formatting on all the five packages):

# strings_compared_04_BIS_FINAL.py
#

from sty import ef, fg, rs

print(f'\n{"I like "}{ef.b + ef.u + fg.li_green + "python-forum" + rs.fg + rs.u + rs.bold_dim}{ef.i + " … a lot!" + rs.i}')

# MY COMMENTS:
#
# 1) The attribute 'bold' doesn't seem to work. Actually, it seems 
# to be maybe a bit brighter, but not 'bold'. 
#  
# 2) The attribute for 'italic' doesn't work here.
#
# 3) The 'underline' works. HOORAY!
#
# 4) For what I've found, it seems that the reason for 'bold', 'italic'
# and other characteristics not working, is due to the computer running
# on a Microsoft Windows Operating System (OS), as it seems that when
# it's running on Ubuntu or similar, there is not such a problem!!!
And finally on this comparison, fifth for colorful (I’ve tried to apply the f-string formatting on all the five packages, but in this case, I find the formatting very similar to f-strings, so I left the 'f' out, keeping the format of colorful):

# strings_compared_05_BIS_FINAL.py
#

import colorful as cf

cf.print('\nI like {c.bold_underlined_green}python-forum{c.reset}{c.italic} ... a lot!{c.reset}')

# MY COMMENTS:
#
# 1) The attribute 'bold' doesn't seem to work. Actually, it seems 
# to be maybe a bit brighter, but not 'bold'. 
#  
# 2) The attribute for 'italic' doesn't work here.
#
# 3) The 'underline' works. HOORAY!
#
# 4) For what I've found, it seems that the reason for 'bold', 'italic'
# and other characteristics not working, is due to the computer running
# on a Microsoft Windows Operating System (OS), as it seems that when
# it's running on Ubuntu or similar, there is not such a problem!!!
#
# I find the format very similar to f-strings formatting (I didn't
# use the f', though).
Here are the image capture of the 5 packages used to print the same string.
[Image: strings-compared-5-packages.png]

where you can see that the output for the five packages is very similar, with the exception of colorama, that hasn’t the style of 'underline'.
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply
#17
I would like to say, as these didn’t do what I wanted, that I tried other things:

I tried curses (yeah, I know that I should be fed up by now, but no, it’s not that!!!).

"The curses library supplies a terminal-independent screen-painting and keyboard-handling facility for text-based terminals; such terminals include VT100s, the Linux console, and the simulated terminal provided by X11 programs such as xterm and rxvt."

So once more, problems with Windows …

I used then, curses for windows
https://pypi.org/project/windows-curses/
but I kept not getting the desired results.

I tried pygments with matplot, which curiously didn’t work on the cmder, but did in my Python 3.7.4 Shell, displaying a beautiful butterfly image on matplot (but I want a nice display while I’m learning to code too).

[Image: butterfly.png]

I tried blessed and blessings (data further down). The author of blessings (last release: Jun‎ ‎21‎, ‎2018) is also the co-author of blessed (last release: Jun‎ ‎20‎, ‎2018). Blessed provides a demo program, written in some Python 2, that I managed to adapt to Python 3, but when I ran it, its output was with no formatting and with the following warning:

Error:
C:\Users\User1\AppData\Local\Programs\Python\Python37\lib\site-packages\blessed\terminal.py:32: UserWarning: One or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win32'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: setraw, cbreak, kbhit, height, width warnings.warn(_MSG_NOSUPPORT)
That means again, problems due to Windows.

Blessings provides a demo program, written in Python 3, but when I ran it, it produced the following error:
Error:
ModuleNotFoundError: No module named 'fcntl'.
That means again, problems due to Windows.


I kept searching for other solutions, like fabulous 0.3.0 (data further down). I thought it could be great, not only for the hype on the site:

"Fabulous is a Python library (and command line tools) designed to make the output of terminal applications look fabulous. Fabulous allows you to print colors, images, and stylized text to the console (without curses.) Fabulous also offers features to improve the usability of Python’s standard logging system."

https://jart.github.io/fabulous/

but for some images I saw there:

[Image: fabulous-demo.png]

Unfortunately, when I tried to run the demo, the following error message appeared:

Error:
ModuleNotFoundError: No module named 'fcntl'
This error seems to be once again related to Windows operating system:

"Since the fcntl module is for unix(like) systems only, it is unlikely the software works on Windows…"

https://github.com/cs01/gdbgui/issues/18

Here I enclose data about other related packages/programs, following a progression from the one with the oldest date of release to the most recent one:

icolor
https://pypi.org/project/icolor/
information on site: Interpolate ANSI colours in strings.
Last release: ‎Jun‎ ‎25‎, ‎2012.

pycolorterm 0.2.1
https://pypi.org/project/pycolorterm/
information on site: PyColorTerm allows you to write coloured and styled lines out in the terminal from Python and in a pythonic way.
Last release: ‎Sep‎ ‎28‎, ‎2013.

colors.py 0.2.2
https://pypi.org/project/colors.py/
information on site: Convert and manipulate colour values.
Last release: ‎Dec‎ ‎14‎, ‎2015.

color 0.1
https://pypi.org/project/color/
information on site: python module for colourize string.
Last release: ‎Apr‎ ‎1‎, ‎2016.

colorclass 2.2.0
https://pypi.org/project/colorclass/
information on site: Colourful worry-free console applications for Linux, Mac OS X, and Windows.
Last release: ‎May‎ ‎15‎, ‎2016.

ansicolors 1.1.8
https://pypi.org/project/ansicolors/
information on site: ANSI colours for Python.
Last release: ‎Jun‎ ‎2‎, ‎2017.

colour 0.1.5
https://pypi.org/project/colour/
information on site: converts and manipulates various colour representation (HSL, RVB, web, X11, ...).
Last release: ‎Nov‎ ‎19‎, ‎2017.

ansicolor 0.2.6
https://pypi.org/project/ansicolor/
information on site: A library to produce ansi colour output and coloured highlighting and diffing.
Last release: ‎Jan‎ ‎22‎, ‎2018.

blessed 1.15.0
https://pypi.org/project/blessed/
Last release: Jun‎ ‎20‎, ‎2018.‎

blessings 1.7
https://pypi.org/project/blessings/
information on site: A thin, practical wrapper around terminal colouring, styling, and positioning.
Last release: ‎Jun‎ ‎21‎, ‎2018.

fabulous 0.3.0
https://pypi.org/project/fabulous/
information on site: Makes your terminal output totally fabulous.
Last release: ‎Jun‎ ‎21‎, ‎2018.

colored 1.3.93
https://pypi.org/project/colored/
information on site: Simple library for colour and formatting to terminal.
Last release: ‎Jul‎ ‎6‎, ‎2018.

click 7.0
https://pypi.org/project/click/
information on site: Composable command line interface toolkit.
Last release: ‎Sep‎ ‎25‎, ‎2018.

Color-Console 10.0
https://pypi.org/project/Color-Console/
information on site: Comprehensive Utility Library for changing the colour of text and background of a python console.
Last release: ‎May‎ ‎22‎, ‎2019.

beautifultable 0.8.0
https://pypi.org/project/beautifultable/
information on site: Print ASCII tables for terminals.
Last release: ‎Aug‎ ‎25‎, ‎2019.

The proof that these styles (or attributes) can be applied and work is this image, produced in bash (a command processor, for the GNU operating system, typically run in a text window, allowing the user to type commands which cause actions), in urxvt (a customizable terminal emulator) with a Zenburn-style colour scheme (Zenburn is a low-contrast colour scheme):

[Image: j7e4i.gif]

where you can see 'italic' (\33[3m), 'underline' (\33[4m), 'blinking' (\33[5m), coloured font (\33[33m), and coloured font-background (\33[44m). Nevertheless, I think it is very difficult to appreciate the 'bold' font (\33[1m).
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply
#18
I was also checking other alternatives, and I found out that with Cmder, you can use an image as a background, something that I didn't know ... Look at my Cmder now!!!:

[Image: wonderful-cmder1.png]

[Image: wonderful-cmder2.png]

[Image: wonderful-cmder3.png]

[Image: wonderful-cmder4.png]

Hooray! Now I only miss the formatting styles I want ... Dance

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply
#19
From a while, Windows 10 cmd has an underline style so you can try to add it to the colorama for instance.
ON my system is located in c:\users\jerry\appdata\roaming\python\python37\site-packages

I like your enthusiasm :)
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#20
(Sep-24-2019, 01:28 PM)wavic Wrote: From a while, Windows 10 cmd has an underline style so you can try to add it to the colorama for instance.
ON my system is located in c:\users\jerry\appdata\roaming\python\python37\site-packages

Thank you! I'm going to try to take it slower, as it seems that I'm using most of my time searching for a nice coding environment, instead of actually coding, which it should be my priority at the moment. Wink

(Sep-24-2019, 01:28 PM)wavic Wrote: I like your enthusiasm :)

I'm starting to believe that it's not enthusiasm, but maybe obsessive–compulsive disorder (OCD). Cry

I think I'm going to set this thread as solved, as it has shown that colouring strings can be done.

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to understand strings and lists of strings Konstantin23 2 761 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  Splitting strings in list of strings jesse68 3 1,766 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  Finding multiple strings between the two same strings Slither 1 2,519 Jun-05-2019, 09:02 PM
Last Post: Yoriz
  lists, strings, and byte strings Skaperen 2 4,225 Mar-02-2018, 02:12 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020