:right-sidebar: True CssSection =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: CssSection(**kwargs) :no-contents-entry: Defines a part of a CSS document. Because sections are nested into one another, you can use :obj:`~gi.repository.CssSection.get_parent` to get the containing region. Constructors ------------ .. rst-class:: interim-class .. class:: CssSection :no-index: .. classmethod:: new(file: ~gi.repository.Gio.File | None, start: ~gi.repository.Gtk.CssLocation, end: ~gi.repository.Gtk.CssLocation) -> ~gi.repository.Gtk.CssSection Creates a new ``GtkCssSection`` referring to the section in the given ``file`` from the ``start`` location to the ``end`` location. :param file: The file this section refers to :param start: The start location :param end: The end location .. classmethod:: new_with_bytes(file: ~gi.repository.Gio.File | None, bytes: ~gi.repository.GLib.Bytes | None, start: ~gi.repository.Gtk.CssLocation, end: ~gi.repository.Gtk.CssLocation) -> ~gi.repository.Gtk.CssSection Creates a new ``GtkCssSection`` referring to the section in the given ``file`` or the given ``bytes`` from the ``start`` location to the ``end`` location. .. versionadded:: 4.16 :param file: The file this section refers to :param bytes: The bytes this sections refers to :param start: The start location :param end: The end location Methods ------- .. rst-class:: interim-class .. class:: CssSection :no-index: .. method:: get_bytes() -> ~gi.repository.GLib.Bytes | None Gets the bytes that ``section`` was parsed from. .. versionadded:: 4.16 .. method:: get_end_location() -> ~gi.repository.Gtk.CssLocation Returns the location in the CSS document where this section ends. .. method:: get_file() -> ~gi.repository.Gio.File | None Gets the file that ``section`` was parsed from. If no such file exists, for example because the CSS was loaded via :obj:`~gi.repository.Gtk.CssProvider.load_from_data`\, then ``NULL`` is returned. .. method:: get_parent() -> ~gi.repository.Gtk.CssSection | None Gets the parent section for the given ``section``\. The parent section is the section that contains this ``section``\. A special case are sections of type ``GTK_CSS_SECTION_DOCUMEN``\T. Their parent will either be ``NULL`` if they are the original CSS document that was loaded by :obj:`~gi.repository.Gtk.CssProvider.load_from_file` or a section of type ``GTK_CSS_SECTION_IMPORT`` if it was loaded with an ``@import`` rule from a different file. .. method:: get_start_location() -> ~gi.repository.Gtk.CssLocation Returns the location in the CSS document where this section starts. .. method:: print_(string: ~gi.repository.GLib.String) -> None :param string: .. method:: to_string() -> str Prints the section into a human-readable text form using :obj:`~gi.repository.Gtk.CssSection.print`\.