pyfax.page

Functions to create teletext pages.

Module Contents

Classes

Color

Enum to store colors.

Line

A line of a teletext page.

Page

A teletext page.

Attributes

BCHARS

COLCHARS

BLOCKCOLCHARS

pyfax.page.BCHARS
class pyfax.page.Color(*args, **kwds)

Bases: enum.Enum

Enum to store colors.

DEFAULT = 0
WHITE = 1
RED = 2
GREEN = 3
BLUE = 4
CYAN = 5
MAGENTA = 6
YELLOW = 7
BLACK = 8
pyfax.page.COLCHARS
pyfax.page.BLOCKCOLCHARS
class pyfax.page.Line

A line of a teletext page.

__str__() str

Convert the line to a string.

__len__() int

Get the length of the line.

start_double_size()

Start a double sized block of text.

end_double_size()

End a double sized block of text.

start_flashing()

Start a flashing block of text.

end_flashing()

End a flashing block of text.

start_fg(color: Color, block: bool = False)

Start a foreground color.

Parameters:
  • color – The color.

  • block – Is this a blocked drawing?

add_text(text: str)

Add text to the line.

Parameters:

text – The text.

add_block(block: str, color: Color, color_after: Color = Color.WHITE)

Add a blocked drawing to the line.

Parameters:
  • block – The blocked drawing. This should have three lines separated by newline characters. xs should be used for filled squares and .s for non-filled squares.

  • color – The color.

  • color_after – The color to use after the blocked drawing

start_bg(color: Color)

Start a background color.

Parameters:

color – The color.

class pyfax.page.Page(page_number: int)

A teletext page.

write(overwrite: bool = False)

Write the page to file in the build directory.

Parameters:

overwrite – Overwrite existing pages?

write_direct(overwrite: bool = False)

Write the page directly to the output directory.

Parameters:

overwrite – Overwrite existing pages?

to_tti() str

Convert the page to a tti string.

set_line(number: int, line: Line)

Set a line of the page.

Parameters:
  • number – The line number.

  • line – The line.

set_tagline(tagline: str)

Set the tagline of the page.

Parameters:

tagline – The tagline.

add_wrapped_text(number: int, text: str, double: bool = False, color: Color = Color.DEFAULT) int

Add wrapped text to the page.

Parameters:
  • number – The line number to start the text.

  • text – The text.

  • double – Should the text be double sized?

  • color – The text color.

Returns:

The line number after the text finishes.

add_block(number: int, block: str, color: Color, bg: Color | None = None, indent: int = 0, color_after: Color = Color.WHITE) int

Add a block drawing to the page.

Parameters:
  • number – The line number to start the block drawing.

  • block – The blocked drawing. This should have a number of lines that is a mutliple of three separated by newline characters. xs should be used for filled squares and .s for non-filled squares.

  • color – The text color.

  • bg – The background color.

  • index – The number of characters to indent the drawing.

  • color_after – The color to use afer the block drawing.

Returns:

The line number after the block drawing finishes.