Printing (and using) formatted text

Formatted text

There are several ways to display colors:

  • By creating a quo.echo() function.

  • By creating a quo.print() function.

An instance of any of these three kinds of objects is called “formated text”.


quo.echo() prints a message plus a newline to the given file or stdout. On first sight, this looks like the print function, but it has improved support for handling Unicode, binary data and formatted text. It will emit newline by default, which cab be suppressed by passing :param:nl=False

» List of supported ANSI colors

  • text – the string to style with ansi or rgb color codes.

  • fg – if provided this will become the foreground color.

  • bg – if provided this will become the background color.

  • bold – if provided this will enable or disable bold mode.

  • dim – if provided this will enable or disable dim mode.

  • nl - if provided this will print a new line.

  • ul or underline – if provided this will enable or disable underline.

  • italic - if provided this will print data in italic.

  • blink – if provided this will enable or disable blinking.

  • strike -if provided this will print a strikethrough text.

  • hidden - if privided this will prevent the input from getting printed.

  • reverse – if provided this will enable or disable inverse rendering (foreground becomes background and the other way round).

  • reset – by default a reset-all code is added at the end of the string which means that styles do not carry over. This can be disabled to compose styles.

from quo import echo

echo("Hello, world!", nl=False)
from quo import echo

echo("This is bold", bold=True)
echo("This is italic", italic=True)

# Colors from the ANSI palette

echo("This is red", fg="red")
echo("This is green", fg="green")
from quo import echo
echo("This is underlined", underline=True)
from quo import echo


Printing to Standard error using echo

You can easily print to standard error by passing :param:err=True

from quo import echo

echo('Hello World!', err=True)


Quo ships with a print() function that’s meant to be (as much as possible) compatible with the built-in print function, and quo.echo(). It also supports color and formatting just like quo.echo(). print() can be used to indicate that a string contains HTML-like formatting. It recognizes the basic tags for bold, italic and underline: <b>, <i> and <u>. Changed since v2022.3.5

On Linux systems, this will output VT100 escape sequences, while on Windows it will use Win32 API calls or VT100 sequences, depending on what is available.

  • values - Any kind of printable object, or formatted string.

  • end - String appended after the last value, default a newline.(the default is a new line).

  • fmt bool - Default is False, if True, you will be able to utilize an instance of quo.text.FormattedText. Added on v2022.4

  • color_depth - Instance of quo.color.ColorDepth . This specifies the number of bits used for each color component i.e: one_bit(2 colors black ad white), four_bit(ANSI 16 colors), eight_bit(256 colors) or twenty_four_bit(24 bit True color). The default color depth is eight_bit.

  • sep - String inserted between values, default a space.

  • style - instance for the color scheme.

from quo import print

print('<b>This is bold</b>')
print('<i>This is italic</i>')
print('<u>This is underlined</u>')
  • Colors from the ANSI palette.

from quo import print

print('<red>This is red</red>')
print('<green>This is green</green>')

» List of supported ANSI colors Read more about styling.

  • Named colors (256 color palette, or true color).

from quo import print

print('<skyblue>This is sky blue</skyblue>')

More examples

from quo import print
print('<seagreen>This is sea green</seagreen>')
print('<violet>This is violet</violet>')

» List of supported Named colors

Both foreground and background colors can also be specified setting the fg and bg attributes of any Text tag:

from quo import print

print('<style fg="white" bg="green">White on green</style>')


» style tag in the example above can be anything i.e: <abc…

Underneath, all Text tags are mapped to classes from a stylesheet, so you can assign a style for a custom tag.

from quo import print
from import Style

style = Style.add({
    'aaa': 'fg:red',
    'bbb': 'fg:blue italic'

print('<aaa>Hello</aaa> <bbb>world</bbb>!', style=style)


This page is also useful if you’d like to learn how to use formatting in other places, like in a prompt or a toolbar.

» Check out more examples here