Actor > Widgets#
Label#
- class miniworlds.actors.widgets.label.Label(position: Tuple[float, float] | None = (0, 0), *args, **kwargs)[source]#
Public Data Attributes:
Inherited from
Buttonfixed_widthchildrenactor_countclass_imageactor_idspeedInherited from
SingleWidgetpadding_leftpadding_rightpadding_toppadding_bottompositionThe position of the actor as Position(x, y)
topleftcenterrow_heighttext_alignDefines how text is aligned.
textThe text which is displayed on the widget.
fixed_widthchildrenactor_countclass_imageactor_idspeedInherited from
BaseWidgetpadding_leftpadding_rightpadding_toppadding_bottompositionThe position of the actor as Position(x, y)
topleftcenterrow_heightfixed_widthchildrenactor_countclass_imageactor_idspeedInherited from
ParentActorvisibleYou can make this sprite disappear without removing it from the group assign 0 for invisible and 1 for visible
layerDefines the layer on which the actor is drawn if several actors overlap.
childrenactor_countclass_imageactor_idspeedInherited from
Actorcollision_type specifies how collisions should be checked:
A actor with the property
is_blockablecannot move through actors with the propertyis_blocking.A actor with the property
is_blockablecannot move through actors with the propertyis_blocking.Defines the layer on which the actor is drawn if several actors overlap.
Actor position in last frame
Returns number of costumes of actor, 0 if actor has no costume
When a actor is mirrored, it is mirrored across the y-axis.
Gets the costume of the actor, if available.
Gets the costume manager
Directions are handled exactly as in the Scratch programming language, see: Scratch Wiki
Gets the direction as value in unit circle (0° right, 90° top, 180° left...)
Size of the actor
The width of the actor in pixels.
The height of the actor in pixels.
The x-value of a actor
The y-value of a actor
x-value of actor topleft-position
x-value of actor topleft-position
x-value of actor center-position inside the current camera-screen
x-value of actor center-position
y-value of actor center-position
Defines if the costume of a actor should be rotatable.
Should actor react to events? You can turn this option off for additional performance boost.
The fill color of actor as rgba value, e.g. (255, 0, 0) for red.
The fill color of actor as rgba value, e.g. (255, 0, 0) for red.
Is actor filled with color?
border color of actor.
border color of actor.
The border-size of actor.
You can make this sprite disappear without removing it from the group assign 0 for invisible and 1 for visible
The image of the actor:
The position of the actor as Position(x, y)
actor_idspeedInherited from
ActorBasedirtyIf actor is dirty, it will be repainted.
rectThe surrounding Rectangle as pygame.Rect.
position_managersensor_managercostume_managerInherited from
DirtySpritevisibleYou can make this sprite disappear without removing it from the group assign 0 for invisible and 1 for visible
layerLayer property can only be set before the sprite is added to a group, after that it is read only and a sprite's layer in a group should be set via the group's change_layer() method.
Inherited from
SpriteimagerectlayerDynamic, read only property for protected _layer attribute.
Public Methods:
__init__(text[, image])Inherited from
Button__init__([text, image])on_clicked_left(mouse_pos)This event is called when the button is clicked -
act()Inherited from
SingleWidget__init__([position])resize()cut_widget_text()update_positions()get_local_pos(position)set_row_height([value])set_border([color, width])sets border of widget
set_position(value)set_world(new_world)get_widget_text()set_image(_img_source)sets image of widget
set_text(text)Sets text of widget.
get_text()Inherited from
BaseWidget__init__([position])new_costume()resize()update_positions()get_local_pos(position)set_row_height(value)set_border([color, width])sets border of widget
set_world(new_world)set_position(value)Inherited from
ParentActor__init__(position[, children])add_child(actor)set_layer(value)set_world(new_world)reset_costumes()before_remove()Inherited from
Actor__init__([position])switch_origin(value)create_on_world(world)Creates a actor to a specific world
from_topleft(topleft_position, *args, **kwargs)Creates a actor with center at center_position
from_center(center_position, *args, **kwargs)Creates a actor with center at center_position
flip_x()Flips the actor by 180° degrees.
add_costume([source])Adds a new costume to actor.
add_costumes(sources)Adds multiple costumes
remove_costume([source])Removes a costume from actor
switch_costume(source)Switches the costume of actor
set_costume(costume)set_background_color(color)Switches to the next costume of actor
turn_left([degrees])Turns actor by degrees degrees left :rtype:
intturn_right([degrees])Turns actor by degrees degrees right
set_direction(direction)Actor points in given direction.
point_towards_position(destination)Actor points towards a given position
point_towards_actor(other)Actor points towards another actor.
set_size(value)scale_width(value)scale_height(value)move([distance, direction])Moves actor distance steps in current direction
move_vector(vector)Moves actor in direction defined by the vector
move_back(distance)Undo the last move.
move_towards(target)move_in_direction(direction[, distance])Moves actor distance steps into a direction or towards a position
move_to(position)Moves actor distance to a specific world_posiition
remove([kill])Removes this actor from world
bounce_from_border(borders)The actor "bounces" from a border.
detect_all([actors, direction, distance])Detects if actors are on actor position.
detect(*args, **kwargs)Detects if actors are on actor position.
detect_borders([distance])Detects borders
Does the actor touch the left border?
Does the actor touch the right border?
Does the actor touch the lower border?
Does the actor touch the lower border?
detect_color([color])Detects colors in world-background at actor center-position
detect_color_at([direction, distance])Detects colors in world-background at actor-position
detect_actors_at([direction, distance, actors])Detects a actor in given direction and distance.
detect_actor_at([direction, distance, actors])detect_actors_in_front([actors, distance])detect_actor_in_front([actors, distance])detect_point(position)Is the actor colliding with a specific (global) point?
detect_pixel(position)Is the actor colliding with a pixel?
detect_rect(rect)Is the actor colliding with a static rect?
Is the actor colliding with current ....
bounce_from_actor(other)animate([speed])animate_costume(costume[, speed])animate_loop([speed])Animates a costume with a looping animation
Stops current animation.
send_message(message)Sends a message to world.
on_key_down(key)on_key_down is called one time when a key is pressed down.
on_key_pressed(key)on_key_pressed is called when while key is pressed.
on_key_up(key)on_mouse_over(position)on_mouse_over is called, when mouse is moved over actor :type position: :param position: The mouse position
on_mouse_leave(position)on_mouse_over is called, when mouse is moved over actor :type position: :param position: The mouse position
on_mouse_left_down(position)on_mouse_right_down(position)on_mouse_left(position)on_mouse_left is called when left mouse button was pressed.
on_mouse_right(position)Method is called when right mouse button was pressed.
on_mouse_motion(position)Method is called when mouse moves.
on_mouse_left_released(position)Method is called when left mouse key is released.
on_mouse_right_released(position)Method is called when right mouse key is released.
on_clicked_left(position)The mouse is on top of a actor and mouse was clicked.
on_clicked_right(position)The mouse is on top of a actor and mouse was clicked.
on_detecting_world is called, when actor is on the world
on_detecting_world is called, when actor is on the world
on_detecting_actor(actor)on_detecting_actor is called, when actor is detects a actor on same position
on_detecting_borders(borders)on_detecting_border is called, when actor is near a border
fill(value)Set fill color for borders and lines
hide()Hides a actor (the actor will be invisible)
show()Displays a actor ( an invisible actor will be visible)
register_sensor(*args, **kwargs)This method is used for the @register_sensor decorator.
set_world(new_world)set_position(value)get_distance_to(obj)Gets the distance to another actor or a position
Inherited from
ActorBaseregister(method[, force, name])This method is used for the @register decorator.
register_message(*args, **kwargs)Registers a method to an object to handle specific on_message events.
__str__()Return str(self).
get_costume_class()Inherited from
DirtySprite__init__(*groups)__repr__()Return repr(self).
Inherited from
Sprite__init__(*groups)add(*groups)add the sprite to groups
remove(*groups)remove the sprite from groups
add_internal(group)For adding this sprite to a group internally.
remove_internal(group)For removing this sprite from a group internally.
update(*args, **kwargs)method to control sprite behavior
kill()remove the Sprite from all Groups
groups()list of Groups that contain this Sprite
alive()does the sprite belong to any groups
__repr__()Return repr(self).
Private Data Attributes:
_abc_implInherited from
Button_abc_impl_visible_layer_world_sensor_manager_position_manager_costume_manager_collision_type_is_acting__image__rectInherited from
SingleWidget_abc_impl_visible_layer_world_sensor_manager_position_manager_costume_manager_collision_type_is_acting__image__rectInherited from
BaseWidget_abc_impl_visible_layer_world_sensor_manager_position_manager_costume_manager_collision_type_is_acting__image__rectInherited from
ParentActor_abc_impl_visible_layer_world_sensor_manager_position_manager_costume_manager_collision_type_is_acting__image__rectInherited from
Actor_abc_impl_world_sensor_manager_position_manager_costume_manager_collision_type_layer_is_acting__image__rectInherited from
ActorBase_abc_impl__image__rectPrivate Methods:
Inherited from
Actor_validate_arguments(position, *args, **kwargs)Inherited from
ActorBase_is_actor_repainted()Inherited from
DirtySprite_set_visible(val)set the visible value (0 or 1) and makes the sprite dirty
_get_visible()return the visible value of that sprite