Theming module

Define the variables (colors and some other stuff) that are used when drawing the interface.

Colors are numbers from -1 to 7 (if only 8 colors are supported) or -1 to 255 if 256 colors are available. If only 8 colors are available, all colors > 8 are converted using the table_256_to_16 dict.

XHTML-IM colors are converted to -1 -> 255 colors if available, or directly to -1 -> 8 if we are in 8-color-mode.

A pair_color is a background-foreground pair. All possible pairs are not created at startup, because that would create 256*256 pairs, and almost all of them would never be used.

A theme should define color tuples, like (200, -1), and when they are to be used by poezio's interface, they will be created once, and kept in a list for later usage. A color tuple is of the form (foreground, background, optional) A color of -1 means the default color. So if you do not want to have a background color, use (x, -1). The optional third value of the tuple defines additional information. It is a string and can contain one or more of these characters:

  • b: bold
  • u: underlined
  • x: blink

For example, (200, 208, 'bu') is bold, underlined and pink foreground on orange background.

A theme file is a python file containing one object named 'theme', which is an instance of a class (derived from the Theme class) defined in that same file. For example, in

import theming
class PinkyTheme(theming.Theme):
    COLOR_NORMAL_TEXT = (200, -1)

theme = PinkyTheme()

if the command '/theme pinkytheme' is issued, we import the file and set the global variable 'theme' to pinkytheme.theme.

And in poezio's code we just use theme.COLOR_NORMAL_TEXT etc

Since a theme inherites from the Theme class (defined here), if a color is not defined in a theme file, the color is the default one.

Some values in that class are a list of color tuple. For example [(1, -1), (2, -1), (3, -1)] Such a list SHOULD contain at least one color tuple. It is used for example to define color gradient, etc.

class poezio.theming.Theme[source]

The theme class, from which all themes should inherit. All of the following values can be replaced in subclasses, in order to create a new theme.

Do not edit this file if you want to change the theme to suit your needs. Create a new theme and share it if you think it can be useful for others.