code: def connect_value(instance, prop, widget, value_range=None, log=False):
      
  
      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(instance, 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(instance, prop, update_widget)
      widget.valueChanged.connect(update_prop)
  
      update_widget(getattr(instance, prop))
docs: Connect a numerical callback property with a Qt widget representing a value.
  
      Parameters
      ----------
      instance : object
          The class instance that the callback property is attached to
      prop : str
          The name of the callback property
      widget : QtWidget
          The Qt widget to connect. This should implement the ``setText`` and
          ``text`` methods as well optionally the ``editingFinished`` signal.
      value_range : iterable, optional
          A pair of two values representing the true range of values (since
          Qt widgets such as sliders can only have values in certain ranges).
      log : bool, optional
          Whether the Qt widget value should be mapped to the log of the callback
          property.