class text_screen.TextScreen(Widget)

The TextScreen class displays pages of text. It is designed to be used as a screen in a Shell. The text is read from a file, and some simple markup is used to divide it into pages with headings. Buttons are provided for navigating between pages and going back to the game's main menu.

Text File

The text file should reside in the text subdirectory of the resources directory (see module resource). Pages are separated by lines containing the word PAGE and nothing else (not even whitespace). The first line of each page is treated as a heading and displayed in a different font.

No word wrapping or other formatting is performed. It is up to you to ensure that each line and page of text fits on the screen in the fonts being used, allowing room for navigation buttons at the bottom.


Initializes the TextScreen from the specified text file, which should be in the text subdirectory of the resources directory. Fonts can be specified for the headings, the body text and the navigation buttons; otherwise defaults are used.

Theme Properties

Font to use for the page headings.
Font to use for the body of the text.
Font to use for the navigation buttons.


Switch to the specified page number.

Switch to the previous page, if any.

Switch to the next page, if any.

Returns to the game's main menu by calling the show_menu() method of the TextScreen's parent widget (which is assumed to be a Shell).