Text
A brief reference to the Text class.
Text extends the Renderable class but has some unique methods that are listed below.
Renderable Quick Reference Text Documentation

Initialization

Text can be initialized like this:
1
text = Text(screen, text, x, y)
Copied!
There an extended constructor that contains most attributes, check the full documentation: Text

Text

You can get or change the text displayed with:
1
text.text() # Get the current text
2
text.text('new string!') # Set new text
Copied!

Font

You can access the font of the text with:
1
text.font() # The current font
2
text.font(font) # Set a new font
Copied!

Size

You can also modify the font-size as expected:
1
text.size() # Retrieve the current font-size
2
text.size(16) # Set a new font-size (~height in pixels)
Copied!
The width() and height() methods will only return the height of the text created as they are determined by text, font, and font-size, and cannot be set.

Align

You can specify an alignment for cases where multiple lines of text are given:
Possible Values (string):
  • left
  • center
  • right
1
text.align(alignment)
Copied!

Decorations

You can decorate text with the following methods:
1
text.bold(True)
2
text.italic(True)
3
text.underline(True)
4
text.strikethrough(True)
Copied!

Last modified 8mo ago