

def connect_value(client, prop, widget, value_range=None, log=False):
    '\n    Connect client.prop to widget.valueChanged\n\n    client.prop should be a callback property\n\n    If ``value_range`` is set, the slider values are mapped to that range. If\n    ``log`` is set, the mapping is assumed to be logarithmic instead of linear.\n    '
    if log:
        if (value_range is None):
            raise ValueError('log option can only be set if value_range is given')
        else:
            value_range = (math.log10(value_range[0]), math.log10(value_range[1]))

    def update_prop():
        val = widget.value()
        if (value_range is not None):
            (imin, imax) = (widget.minimum(), widget.maximum())
            val = ((((val - imin) / (imax - imin)) * (value_range[1] - value_range[0])) + value_range[0])
        if log:
            val = (10 ** val)
        setattr(client, prop, val)

    def update_widget(val):
        if (val is None):
            widget.setValue(0)
            return
        if log:
            val = math.log10(val)
        if (value_range is not None):
            (imin, imax) = (widget.minimum(), widget.maximum())
            val = ((((val - value_range[0]) / (value_range[1] - value_range[0])) * (imax - imin)) + imin)
        widget.setValue(val)
    add_callback(client, widget, update_widget)
    widget.valueChanged.connect(update_prop)
    update_widget(getattr(client, prop))

dataset/ETHPy150Open glue-viz/glue/glue/utils/qt/widget_properties.py connect_value/VarMisuse@306/487 `prop`->`widget`