Reference 〉 Function

Helipad.addButton(textstr, funcfunc(model), descstrNone)

Adds a button to the control panel, in the shocks section, that runs the func function when pressed. This method is aliased by the @button function decorator, which is simpler to use.

Parameters

  • text str, required

    The text to be displayed on the button.

  • func func(model), required

    The function to be executed when the button is pressed. The function takes one argument, the model object.

  • desc str, optional

    A long description to display as a tooltip.

    Default value: None

Notes and Examples

  1. charwick

    Mar 27, 2020 at 23:02

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

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

    addButton example

  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.

History