Token.Texts and Numbers

TextToken

class miniworldmaker.tokens.text_token.TextToken(position=None, text='', font_size=80, color=(255, 255, 255, 255))[source]

A Text-Token is a token which contains a Text.

You have to set the size of the token with self.size() manually so that the complete text can be seen.

Parameters
  • position – Top-Left position of Text

  • text – The initial text

  • font-size – The size of the font (default: 80)

  • color – The color of the font (default: white)

Examples

Create a new text_token:

self.text = TextToken((1,1), "Hello World")
property auto_size

Gets auto size value: * “token”: token is autosized by font size * “font”: font is autosized by token size * None: no autosizing

get_text()[source]

Gets the currently displayed tex

Returns

The currently displayed text

set_auto_size()[source]

Sets self.size by costume.font_size

set_text(text)[source]

Sets the text of the token

Parameters

text – The text

NumberToken

class miniworldmaker.tokens.number_token.NumberToken(*args, **kwargs)[source]

A number token shows a Number.

You have to set the size of the token with self.size() manually so that the complete text can be seen.

Parameters
  • position – Top-Left position of Number

  • number – The initial number

  • font-size – The size of the font (default: 80)

  • color – The color of the font (default: white)

Examples

Sets a new NumberToken to display the score.:

self.score = NumberToken(position = (0, 0) number=0)

Gets the number stored in the NumberToken:

number = self.score.get_number()

Sets the number stored in the NumberToken:

self.score.set_number(3)
get_number()[source]
Returns

The current number

Examples

Gets the number stored in the NumberToken:

number = self.number_token.get_number()
Return type

int

inc()[source]

Increases the number by one

set_number(number)[source]

Sets the number

Parameters

number – The number which should be displayed

Examples

Sets the number stored in the NumberToken:

self.number_token.set_number(3)