Token.Texts and Numbers

Token.Texts and Numbers

TextToken

class miniworldmaker.tokens.text_token.Text(*args, **kwargs)[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

Examples

Create a new text_token:

self.text = TextToken((1,1), "Hello World")
property font_size
get_text()[source]

Gets the currently displayed tex

Returns:

The currently displayed text

set_text(text)[source]

Sets the text of the token

Parameters:

text – The text

property text

changes the text.

class miniworldmaker.tokens.text_token.TextToken(*args, **kwargs)[source]

Alias for legacy code

NumberToken

class miniworldmaker.tokens.number_token.Number(*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)

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)
class miniworldmaker.tokens.number_token.NumberToken(*args, **kwargs)[source]

Alias for legacy code