Token: Texts and Numbers

Token: Texts and Numbers

Texts

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

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

You have to set the sget_tokens_atize 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.

Numbers

class miniworldmaker.tokens.token_plugins.text_token.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)
add(value)[source]

add the sprite to groups

Sprite.add(*groups): return None

Any number of Group instances can be passed as arguments. The Sprite will be added to the Groups it is not already a member of.

get_number()
Returns:

The current number

Examples

Gets the number stored in the NumberToken:

number = self.number_token.get_number()
Return type:

int

get_value()[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)

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)
set_value(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)
sub(value)[source]
update_text()[source]