Skip to content

Exit actuator

Implementation of an actuator that will close the window when the escape key is pressed.

ExitActuator

Bases: Actuator

AvatarActuator for the MATBII avatar.

Source code in matbii\avatar\exit_actuator.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class ExitActuator(Actuator):
    """AvatarActuator for the MATBII avatar."""

    @attempt
    def exit(self, action: KeyEvent):
        """Attempt method for a `KeyEvent` that will convert a press to `Esc` to a `WindowCloseEvent`, triggering the environment to terminate.

        Args:
            action (KeyEvent): user input event.

        Returns:
            WindowCloseEvent: event to close the window.
        """
        if isinstance(action, KeyEvent):
            if action.key == "escape":
                LOGGER.info("Escape was pressed, shutting down...")
                return WindowCloseEvent()

exit(action)

Attempt method for a KeyEvent that will convert a press to Esc to a WindowCloseEvent, triggering the environment to terminate.

Parameters:

Name Type Description Default
action KeyEvent

user input event.

required

Returns:

Name Type Description
WindowCloseEvent

event to close the window.

Source code in matbii\avatar\exit_actuator.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@attempt
def exit(self, action: KeyEvent):
    """Attempt method for a `KeyEvent` that will convert a press to `Esc` to a `WindowCloseEvent`, triggering the environment to terminate.

    Args:
        action (KeyEvent): user input event.

    Returns:
        WindowCloseEvent: event to close the window.
    """
    if isinstance(action, KeyEvent):
        if action.key == "escape":
            LOGGER.info("Escape was pressed, shutting down...")
            return WindowCloseEvent()