CssSection#

class CssSection(**kwargs)#

Defines a part of a CSS document.

Because sections are nested into one another, you can use get_parent to get the containing region.

Constructors#

class CssSection
classmethod new(file: File | None, start: CssLocation, end: CssLocation) CssSection#

Creates a new GtkCssSection referring to the section in the given file from the start location to the end location.

Parameters:
  • file – The file this section refers to

  • start – The start location

  • end – The end location

classmethod new_with_bytes(file: File | None, bytes: Bytes | None, start: CssLocation, end: CssLocation) 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.

Added in version 4.16.

Parameters:
  • file – The file this section refers to

  • bytes – The bytes this sections refers to

  • start – The start location

  • end – The end location

Methods#

class CssSection
get_bytes() Bytes | None#

Gets the bytes that section was parsed from.

Added in version 4.16.

get_end_location() CssLocation#

Returns the location in the CSS document where this section ends.

get_file() File | None#

Gets the file that section was parsed from.

If no such file exists, for example because the CSS was loaded via load_from_data, then NULL is returned.

get_parent() 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 load_from_file or a section of type GTK_CSS_SECTION_IMPORT if it was loaded with an `import` rule from a different file.

get_start_location() CssLocation#

Returns the location in the CSS document where this section starts.

print_(string: String) None#
Parameters:

string

to_string() str#

Prints the section into a human-readable text form using print.