Exemplo n.º 1
0
    def __init__(self, name=None, serve_locally=False,
                 expanded_callbacks=False,
                 add_bootstrap_links=False,
                 suppress_callback_exceptions=False,
                 **kwargs): # pylint: disable=unused-argument
        if name is None:
            global uid_counter # pylint: disable=global-statement
            uid_counter += 1
            self._uid = "djdash_%i" % uid_counter
        else:
            self._uid = name
        self.layout = None
        self._callback_sets = []

        self.css = Holder()
        self.scripts = Holder()

        add_usable_app(self._uid,
                       self)

        self._expanded_callbacks = expanded_callbacks
        self._serve_locally = serve_locally
        self._suppress_callback_exceptions = suppress_callback_exceptions

        if add_bootstrap_links:
            from bootstrap4.bootstrap import css_url
            bootstrap_source = css_url()['href']
            self.css.append_script({'external_url':[bootstrap_source,]})
Exemplo n.º 2
0
    def __init__(self,
                 name=None,
                 serve_locally=None,
                 expanded_callbacks=False,
                 add_bootstrap_links=False,
                 suppress_callback_exceptions=False,
                 **kwargs):  # pylint: disable=unused-argument, too-many-arguments

        if name is None:
            global uid_counter  # pylint: disable=global-statement
            uid_counter += 1
            self._uid = "djdash_%i" % uid_counter
        else:
            self._uid = name
        self.layout = None
        self._callback_sets = []
        self._clientside_callback_sets = []

        self.css = Holder()
        self.scripts = Holder()

        add_usable_app(self._uid, self)

        if serve_locally is None:
            self._serve_locally = serve_locally_setting()
        else:
            self._serve_locally = serve_locally

        self._expanded_callbacks = expanded_callbacks
        self._suppress_callback_exceptions = suppress_callback_exceptions

        if add_bootstrap_links:
            from bootstrap4.bootstrap import css_url
            bootstrap_source = css_url()['href']

            if self._serve_locally:
                # Ensure package is loaded; if not present then pip install dpd-static-support
                import dpd_static_support
                hard_coded_package_name = "dpd_static_support"
                base_file_name = bootstrap_source.split('/')[-1]

                self.css.append_script({
                    'external_url': [
                        bootstrap_source,
                    ],
                    'relative_package_path': base_file_name,
                    'namespace': hard_coded_package_name,
                })
            else:
                self.css.append_script({
                    'external_url': [
                        bootstrap_source,
                    ],
                })

        # Remember some caller info for static files
        caller_frame = inspect.stack()[1]
        self.caller_module = inspect.getmodule(caller_frame[0])
        self.caller_module_location = inspect.getfile(self.caller_module)
        self.assets_folder = "assets"
Exemplo n.º 3
0
def bootstrap_css_url():
    """
        Return the full url to the Bootstrap CSS library
        Default value: ``None``
        This value is configurable, see Settings section
        **Tag name**::
            bootstrap_css_url
        **Usage**::
            {% bootstrap_css_url %}
        **Example**::
            {% bootstrap_css_url %}
        """
    return css_url()
Exemplo n.º 4
0
    def __init__(
            self,
            name=None,
            serve_locally=False,
            expanded_callbacks=False,
            add_bootstrap_links=False,
            app_name=None,  # EB added: app_name
            **kwargs):  # pylint: disable=unused-argument
        if name is None:
            global uid_counter  # pylint: disable=global-statement
            uid_counter += 1
            self._uid = "djdash_%i" % uid_counter
        else:
            self._uid = name

        # EB added:
        if app_name:
            self.content_redirect_url = "/".join([app_name, self._uid])
        # End EB added:

        self.layout = None
        self._callback_sets = []

        self.css = Holder()
        self.scripts = Holder()

        add_usable_app(self._uid, self)

        self._expanded_callbacks = expanded_callbacks
        self._serve_locally = serve_locally

        if add_bootstrap_links:
            from bootstrap4.bootstrap import css_url
            bootstrap_source = css_url()['href']
            self.css.append_script({'external_url': [
                bootstrap_source,
            ]})
Exemplo n.º 5
0
    def __init__(self,
                 name=None,
                 serve_locally=False,
                 expanded_callbacks=False,
                 add_bootstrap_links=False,
                 suppress_callback_exceptions=False,
                 **kwargs):  # pylint: disable=unused-argument, too-many-arguments
        if name is None:
            global uid_counter  # pylint: disable=global-statement
            uid_counter += 1
            self._uid = "djdash_%i" % uid_counter
        else:
            self._uid = name
        self.layout = None
        self._callback_sets = []

        self.css = Holder()
        self.scripts = Holder()

        add_usable_app(self._uid, self)

        self._expanded_callbacks = expanded_callbacks
        self._serve_locally = serve_locally
        self._suppress_callback_exceptions = suppress_callback_exceptions

        if add_bootstrap_links:
            from bootstrap4.bootstrap import css_url
            bootstrap_source = css_url()['href']
            self.css.append_script({'external_url': [
                bootstrap_source,
            ]})

        # Remember some caller info for static files
        caller_frame = inspect.stack()[1]
        self.caller_module = inspect.getmodule(caller_frame[0])
        self.caller_module_location = inspect.getfile(self.caller_module)
Exemplo n.º 6
0
    def __init__(self,
                 name=None,
                 serve_locally=None,
                 add_bootstrap_links=False,
                 suppress_callback_exceptions=False,
                 external_stylesheets=None,
                 external_scripts=None,
                 **kwargs):  # pylint: disable=unused-argument, too-many-arguments

        # store arguments to pass them later to the WrappedDash instance
        self.external_stylesheets = external_stylesheets or []
        self.external_scripts = external_scripts or []
        self._kwargs = kwargs
        if kwargs:
            warnings.warn(
                "You are passing extra arguments {kwargs} that will be passed to Dash(...) "
                "but may not be properly handled by django-plotly-dash.".
                format(kwargs=kwargs))

        if name is None:
            global uid_counter  # pylint: disable=global-statement
            uid_counter += 1
            self._uid = "djdash_%i" % uid_counter
        else:
            self._uid = name
        self.layout = None
        self._callback_sets = []
        self._clientside_callback_sets = []

        self.css = Holder()
        self.scripts = Holder()

        add_usable_app(self._uid, self)

        if serve_locally is None:
            self._serve_locally = serve_locally_setting()
        else:
            self._serve_locally = serve_locally

        self._suppress_callback_exceptions = suppress_callback_exceptions

        if add_bootstrap_links:
            from bootstrap4.bootstrap import css_url
            bootstrap_source = css_url()['href']

            if self._serve_locally:
                # Ensure package is loaded; if not present then pip install dpd-static-support
                hard_coded_package_name = "dpd_static_support"
                base_file_name = bootstrap_source.split('/')[-1]

                self.css.append_script({
                    'external_url': [
                        bootstrap_source,
                    ],
                    'relative_package_path': base_file_name,
                    'namespace': hard_coded_package_name,
                })
            else:
                self.css.append_script({
                    'external_url': [
                        bootstrap_source,
                    ],
                })

        # Remember some caller info for static files
        caller_frame = inspect.stack()[1]
        self.caller_module = inspect.getmodule(caller_frame[0])
        try:
            self.caller_module_location = inspect.getfile(self.caller_module)
        except:
            self.caller_module_location = None
        self.assets_folder = "assets"