Reference 〉Function

Helipad.addButton( str text, func(model) func, str desc = None )

Adds a button to the control panel, in the shocks section, that runs the func function when pressed.

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. Note that tooltips require PMW when using the Tkinter frontend.

    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.

    heli = Helipad()
    def reset():
    	for a in heli.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