Reference 〉 Decorator

@Helipad.button(namestrNone, descstrNone)

A function decorator that adds a button to the control panel, in the shocks section, that runs the function when the button is pressed. This decorator can be used bare (i.e. without parentheses), in which case the button is labelled with the name of the function, or it can take optional arguments as necessary.

The decorated function should take one argument, the model object.


  • name str, optional

    The text to be displayed on the button.

    Default value: None

  • desc str, optional

    A long description to display as a tooltip.

    Default value: None

Notes and Examples

  1. charwick

    Aug 06, 2020 at 4:05

    This example creates a button that zeroes out agents’ gold holdings when pressed.

    @heli.button('Reset Wealth', desc='Zeroes out agents' gold holdings.')
    def reset(model):
    	for a in model.agents['agent']:
    		a.stocks['gold'] = 0

    addButton example

    If the decorator were used bare (i.e. just @heli.button), the button would be labeled with the name of the function, ‘reset’.

  2. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.