:right-sidebar: True CssProvider =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: CssProvider(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gtk.StyleProvider` :Constructors: :: CssProvider(**properties) new() -> Gtk.CssProvider Constructors ------------ .. rst-class:: interim-class .. class:: CssProvider :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.CssProvider Returns a newly created ``GtkCssProvider``. Methods ------- .. rst-class:: interim-class .. class:: CssProvider :no-index: .. method:: load_from_bytes(data: ~gi.repository.GLib.Bytes) -> None Loads ``data`` into ``css_provider``. This clears any previously loaded information. .. versionadded:: 4.12 :param data: ``GBytes`` containing the data to load .. method:: load_from_data(text, length=-1) Loads ``data`` into ``css_provider``. This clears any previously loaded information. .. deprecated:: 4.12 Use :obj:`~gi.repository.Gtk.CssProvider.load_from_string` or :obj:`~gi.repository.Gtk.CssProvider.load_from_bytes` instead :param text: :param length: the length of ``data`` in bytes, or -1 for NUL terminated strings .. method:: load_from_file(file: ~gi.repository.Gio.File) -> None Loads the data contained in ``file`` into ``css_provider``. This clears any previously loaded information. :param file: ``GFile`` pointing to a file to load .. method:: load_from_path(path: str) -> None Loads the data contained in ``path`` into ``css_provider``. This clears any previously loaded information. :param path: the path of a filename to load, in the GLib filename encoding .. method:: load_from_resource(resource_path: str) -> None Loads the data contained in the resource at ``resource_path`` into the ``css_provider``. This clears any previously loaded information. :param resource_path: a ``GResource`` resource path .. method:: load_from_string(string: str) -> None Loads ``string`` into ``css_provider``. This clears any previously loaded information. .. versionadded:: 4.12 :param string: the CSS to load .. method:: load_named(name: str, variant: str | None = None) -> None Loads a theme from the usual theme paths. The actual process of finding the theme might change between releases, but it is guaranteed that this function uses the same mechanism to load the theme that GTK uses for loading its own theme. :param name: A theme name :param variant: variant to load, for example, "dark", or :const:`None` for the default .. method:: to_string() -> str Converts the ``provider`` into a string representation in CSS format. Using :obj:`~gi.repository.Gtk.CssProvider.load_from_string` with the return value from this function on a new provider created with :obj:`~gi.repository.Gtk.CssProvider.new` will basically create a duplicate of this ``provider``. Signals ------- .. rst-class:: interim-class .. class:: CssProvider.signals :no-index: .. method:: parsing_error(section: ~gi.repository.Gtk.CssSection, error: ~gi.repository.GLib.GError) -> None Signals that a parsing error occurred. The ``path``, ``line`` and ``position`` describe the actual location of the error as accurately as possible. Parsing errors are never fatal, so the parsing will resume after the error. Errors may however cause parts of the given data or even all of it to not be parsed at all. So it is a useful idea to check that the parsing succeeds by connecting to this signal. Note that this signal may be emitted at any time as the css provider may opt to defer parsing parts or all of the input to a later time than when a loading function was called. :param section: section the error happened in :param error: The parsing error Fields ------ .. rst-class:: interim-class .. class:: CssProvider :no-index: .. attribute:: parent_instance