Exemplo n.º 1
0
    def add_sidebar(self, widget: Component) -> None:
        """Add a widget to the sidebar.

        Parameters
        ----------
        widget : bowtie._Component
            Add this widget to the sidebar, it will be appended to the end.

        """
        if not self.sidebar:
            raise NoSidebarError(
                'Set `sidebar=True` if you want to use the sidebar.')

        assert isinstance(widget, Component)

        # pylint: disable=protected-access
        if widget._PACKAGE:
            self._packages.add(widget._PACKAGE)
        self._templates.add(widget._TEMPLATE)
        self._imports.add(
            _Import(component=widget._COMPONENT,
                    module=widget._TEMPLATE[:widget._TEMPLATE.find('.')]))
        self._controllers.append(
            _Control(instantiate=widget._instantiate,
                     caption=getattr(widget, 'caption', None)))
Exemplo n.º 2
0
    def add_sidebar(self, component: Component) -> None:
        """Add a widget to the sidebar.

        Parameters
        ----------
        component : bowtie._Component
            Add this component to the sidebar, it will be appended to the end.

        """
        if not self.sidebar:
            raise NoSidebarError('Set `sidebar=True` if you want to use the sidebar.')

        if not isinstance(component, Component):
            raise ValueError('component must be Component type, found {}'.format(component))
        # self._track_widget(widget)
        self._controllers.append(component)  # pylint: disable=protected-access