Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
colouring strings
#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


Messages In This Thread
colouring strings - by newbieAuggie2019 - Sep-17-2019, 03:06 AM
RE: colouring strings - by wavic - Sep-17-2019, 03:14 AM
RE: colouring strings - by newbieAuggie2019 - Sep-17-2019, 04:23 PM
RE: colouring strings - by snippsat - Sep-17-2019, 04:42 PM
RE: colouring strings - by newbieAuggie2019 - Sep-17-2019, 09:46 PM
RE: colouring strings - by newbieAuggie2019 - Sep-17-2019, 04:48 PM
RE: colouring strings - by snippsat - Sep-17-2019, 05:13 PM
RE: colouring strings - by newbieAuggie2019 - Sep-17-2019, 05:37 PM
RE: colouring strings - by snippsat - Sep-17-2019, 06:22 PM
RE: colouring strings - by wavic - Sep-17-2019, 08:50 PM
RE: colouring strings - by snippsat - Sep-17-2019, 10:11 PM
RE: colouring strings - by newbieAuggie2019 - Sep-20-2019, 07:27 AM
RE: colouring strings - by wavic - Sep-18-2019, 08:25 AM
RE: colouring strings - by wavic - Sep-18-2019, 11:10 AM
RE: colouring strings - by newbieAuggie2019 - Sep-20-2019, 06:34 PM
RE: colouring strings - by newbieAuggie2019 - Sep-22-2019, 07:12 AM
RE: colouring strings - by newbieAuggie2019 - Sep-22-2019, 09:07 AM
RE: colouring strings - by jquast - Oct-22-2019, 02:28 PM
RE: colouring strings - by newbieAuggie2019 - Oct-22-2019, 03:31 PM
RE: colouring strings - by newbieAuggie2019 - Sep-24-2019, 10:42 AM
RE: colouring strings - by wavic - Sep-24-2019, 01:28 PM
RE: colouring strings - by newbieAuggie2019 - Sep-30-2019, 08:20 PM
RE: colouring strings - by jquast - Oct-23-2019, 03:44 AM
RE: colouring strings - by newbieAuggie2019 - Oct-23-2019, 08:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to understand strings and lists of strings Konstantin23 2 934 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  Splitting strings in list of strings jesse68 3 1,918 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  Finding multiple strings between the two same strings Slither 1 2,636 Jun-05-2019, 09:02 PM
Last Post: Yoriz
  lists, strings, and byte strings Skaperen 2 4,358 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