How to use the traitlets.observe function in traitlets

To help you get started, we’ve selected a few traitlets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Unidata / MetPy / src / metpy / plots / declarative.py View on Github external
    @observe('colors', 'formats', 'locations', 'reduce_points', 'vector_field_color')
    def _set_need_rebuild(self, _):
        """Handle changes to attributes that need to regenerate everything."""
        # Because matplotlib doesn't let you just change these properties, we need
        # to trigger a clear and re-call of contour()
        self.clear()
github ipython / ipyparallel / ipyparallel / apps / launcher.py View on Github external
    @observe('queue')
    def _queue_changed(self, change):
        self._update_context(change)
github NVIDIA-AI-IOT / jetracer / jetracer / nvidia / racecar.py View on Github external
    @traitlets.observe('throttle')
    def _on_throttle(self, change):
        self.throttle_motor.throttle = change['new'] * self.throttle_gain.value
github WorldWideTelescope / pywwt / pywwt / core.py View on Github external
    @observe('foreground')
    def _on_foreground_change(self, changed):
        self._send_msg(event='set_foreground_by_name', name=changed['new'])
        # Changing a layer resets the opacity, so we re-trigger the opacity setting
        self._send_msg(event='set_foreground_opacity',
                       value=self.foreground_opacity * 100)
github ipython / ipyparallel / ipyparallel / controller / scheduler.py View on Github external
    @observe('scheme_name')
    def _scheme_name_changed(self, change):
        self.log.debug("Using scheme %r" % change['new'])
        self.scheme = globals()[change['new']]
github jupyter-widgets / ipywidgets / ipywidgets / widgets / widget_selection.py View on Github external
    @observe('value')
    def _propagate_value(self, change):
        if change.new is None:
            index = None
        elif self.index is not None and self._options_values[self.index] == change.new:
            index = self.index
        else:
            index = self._options_values.index(change.new)
        if self.index != index:
            self.index = index
github descarteslabs / descarteslabs-python / descarteslabs / workflows / interactive / lonlat.py View on Github external
    @traitlets.observe("model")
    def _sync_model_to_view(self, change):
        new = change["new"]
        string = "{:.4f}, {:.4f}".format(
            # https://xkcd.com/2170/
            *(reversed(new) if self.model_is_latlon else new)
        )
        self.value = string
github creare-com / podpac / podpac / core / coordinates / dependent_coordinates.py View on Github external
    @tl.observe("dims", "idims")
    def _set_property(self, d):
        self._properties.add(d["name"])
github jupyter-widgets / ipywidgets / ipywidgets / widgets / widget.py View on Github external
    @observe('comm')
    def _comm_changed(self, change):
        """Called when the comm is changed."""
        if change['new'] is None:
            return
        self._model_id = self.model_id

        self.comm.on_msg(self._handle_msg)
        Widget.widgets[self.model_id] = self
github nintendops / DynamicFusion_Body / ENV / lib / python3.5 / site-packages / IPython / core / application.py View on Github external
    @observe('ipython_dir')
    def _ipython_dir_changed(self, change):
        old = change['old']
        new = change['new']
        if old is not Undefined:
            str_old = py3compat.cast_bytes_py2(os.path.abspath(old),
                sys.getfilesystemencoding()
            )
            if str_old in sys.path:
                sys.path.remove(str_old)
        str_path = py3compat.cast_bytes_py2(os.path.abspath(new),
            sys.getfilesystemencoding()
        )
        sys.path.append(str_path)
        ensure_dir_exists(new)
        readme = os.path.join(new, 'README')
        readme_src = os.path.join(get_ipython_package_dir(), u'config', u'profile', 'README')