botón#
El cerebro EXP tiene acceso a tres objetos para sus tres botones:
buttonCheckbuttonLeftbuttonRight
apretado()#
The pressed(callback, arg) method registers a function to be called when a button is pressed.
Parámetros |
Descripción |
|---|---|
|
Una función que se llamará cuando se presione el botón. |
|
Opcional. Una tupla que se utiliza para pasar argumentos a la función de devolución de llamada. |
Devuelve: Una instancia de la clase Event.
# Define a function button_pressed().
def button_pressed():
# The Brain will print that the button was pressed on
# the Brain's screen.
brain.screen.print("button pressed")
# Run button_pressed() when the left button is pressed.
brain.buttonLeft.pressed(button_pressed)
liberado()#
The released(callback, arg) method registers a function to be called when a button is released.
Parámetros |
Descripción |
|---|---|
|
Una función que se llamará cuando se suelte el botón. |
|
Opcional. Una tupla que se utiliza para pasar argumentos a la función de devolución de llamada. |
Devuelve: Una instancia de la clase Event.
# Define a function button_released().
def button_released():
# The Brain will print that the button was released on
# the Brain's screen.
brain.screen.print("button released")
# Run button_released() when the left button is released.
brain.buttonLeft.released(button_released)
prensado()#
The pressing() method returns whether a button is currently being pressed.
Returns: True if the button is being pressed. False if it is not.