Reference 〉 Class

Param()

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

Param objects are stored in the Params object stored in the model.params property. 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.

  • disable( )

    Disables the parameter's control panel GUI element so that it cannot be interacted with or changed by the user. Note that this does not prevent the value from being updated in code using param.set().

  • disabled( val )

    Enables or disables the parameter's GUI element. Note that disabling does not prevent the value from being updated in code using param.set().

  • enable( )

    Enables the parameter's control panel GUI element so that it can be interacted with by the user.

  • 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 Goods.add() as necessary.

  • get( item )

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

  • set( val, item )

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

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

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

  • per 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|Ipywidgets.widget

    The Tkinter or Ipywidgets widget corresponding to the parameter, or the frame/accordion containing the various parameters in the case of per-good or per-breed parameters. This property is added after the GUI is launched and will not be available prior.

    Initial value:

  • elements dict{str:Tkinter.widget|Ipywidgets.widget}

    For per-breed or per-good parameters, or checkgrids, a dict of interface elements, children of the element parameter. This property is added after the GUI is launched and will not be available prior.

Static Properties

  • type str

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

  • 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