pygamelib.board_items.TextItem

class pygamelib.board_items.TextItem(text=None, **kwargs)

New in version 1.2.0.

The text item is a board item that can contains text. The text can then be manipulated and placed on a Board.

It is overall a BoardComplexItem (so it takes all the parameters of that class). The big difference is that the first parameter is the text you want to display.

The text parameter can be either a regular string or a Text object (in case you want formatting and colors).

Parameters:text (str | Text) – The text you want to display.

Example:

city_name = TextItem('Super City')
fancy_city_name = TextItem(text=base.Text('Super City', base.Fore.GREEN,
    base.Back.BLACK,
    base.Style.BRIGHT
))
my_board.place_item(city_name, 0, 0)
my_board.place_item(fancy_city_name, 1, 0)
__init__(text=None, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([text]) Initialize self.
can_move() This is a virtual method that must be implemented in deriving classes.
collides_with(other) Tells if this item collides with another item.
column Convenience method to get the current stored column of the item.
debug_info() Return a string with the list of the attributes and their current value.
display() Print the model WITHOUT carriage return.
distance_to(other) Calculates the distance with an item.
height Convenience method to get the height of the item.
inventory_space() This is a virtual method that must be implemented in deriving class.
item(row, column) Return the item at the row, column position if it is within the item’s boundaries.
overlappable() This is a virtual method that must be implemented in deriving class.
pickable() This is a virtual method that must be implemented in deriving class.
position_as_vector() Returns the current item position as a Vector2D
row Convenience method to get the current stored row of the item.
store_position(row, column) Store the BoardItem position for self access.
update_sprite() Update the complex item with the current sprite.
width Convenience method to get the width of the item.

Attributes

text The text within the item.