Reference 〉Class

Param( )

Stores data related to registered parameters, including per-breed and per-good parameters. Should not be instantiated directly; use model.addParameter(), model.addGoodParam(), or model.addBreedParam() instead. Most of the properties of the Param object correspond to arguments specified in these functions.

Param objects are stored in model.params, model.goodParams, and Breed.breedParams. Each parameter type is also subclassed by a specific class: MenuParam, CheckParam, SliderParam, and so on. So far as possible they interface identically.

Methods

Click a method name for more detailed documentation.

  • reset( )

    Resets the parameter to its default values.

  • addKey( key )

    If a per-breed or per-good parameter is instantiated and then a breed or good is added, this function updates the parameter with the new breed or good and assigns it the default value specified at the Param object's instantiation.

    This function should not be called directly; it is called automatically by model.addBreed() and model.addGood() as necessary.

  • set( val, item )

    Sets the value of the parameter. Should not be called directly; use model.param() instead.

  • get( item )

    Retrieves the value of the parameter. Should not be called directly; use model.param() instead.

Properties

  • value tkinter.StringVar|tkinter.BooleanVar|num

    The current value of the variable, stored as a StringVar, BooleanVar, or a number, depending on whether the parameter is registered as a menu, a checkbox, or a slider. Do not modify or access directly; use model.param(), model.goodParam(), or model.breedParam() instead.

  • title str

    The title of the parameter, displayed in the control panel.

  • type str

    The type of the parameter, either 'menu', 'check', 'slider', 'checkentry', 'checkgrid', or 'hidden'.

  • default str|bool|num|list|dict

    The default value of the parameter, the type of which depends on Param.type. Takes a dict of values in the case of a per-good or per-breed parameter.

  • opts dict|list

    Options, depending on the type of the parameter. See model.addParameter() for the structure.

  • runtime bool

    Whether the parameter can be modified during the model's runtime. If False, the parameter will be disabled in the control panel while a model is active.

  • callback func

    A callback function to run when the parameter is updated.

  • desc str

    A long description to display as a tooltip. Note that tooltips require PMW when using the Tkinter frontend.

  • obj str

    Either None, 'breed', or 'good', depending on whether it's a global, a per-breed, or a per-good parameter, respectively.

  • range list

    A list of possible values that the parameter can take, depending on the value of param.type.

    • If 'check': True and False.
    • 'menu': The option names given in the opts argument of model.addParameter().
    • 'slider': all increments of the step value between the low and high values, or (in the case of a logslider) the prespecified values entered in the opts parameter of model.addParameter().
    • 'checkgrid': All combinations of selected elements. Note that len(param.range) will increase explosively with the number of items.
    • 'checkentry': None (it is not possible to parameter-sweep a checkentry parameter).
    Note that shocks and floating point errors can both cause the parameter on a slider to take a value that is not an element of this list.

  • element Tkinter.widget|dict

    The Tkinter widget corresponding to the parameter, or a dict of such widgets in the case of a per-breed or per-good parameter. This property is added after the GUI is launched and will not be available prior.

    Initial value:

  • defaultVal bool|str|int|list

    A static property with a type-appropriate fallback value in case param.default is not specified on init. False for checks and checkentries, the first item for menus, [] for checkgrids, and param.opts['low'] for sliders.

Notes and Examples

  1. 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