Skip to content

Gtk.IconPaintable

class — extends GObject.Object, Gdk.Paintable, SymbolicPaintable

Contains information found when looking up an icon in GtkIconTheme or loading it from a file.

GtkIconPaintable implements GdkPaintable and GtkSymbolicPaintable.

Constructors

new_for_file

@classmethod
def new_for_file(cls, file: Gio.File, size: int, scale: int) -> IconPaintable

Creates a GtkIconPaintable for a file with a given size and scale.

The icon can then be rendered by using it as a GdkPaintable.

Parameters:

  • file — a GFile
  • size — desired icon size, in application pixels
  • scale — the desired scale

Methods

get_file

def get_file(self) -> Gio.File | None

Gets the GFile that was used to load the icon.

Returns None if the icon was not loaded from a file.

get_icon_name

def get_icon_name(self) -> str | None

:::warning Deprecated since 4.20 This API is deprecated. :::

Get the icon name being used for this icon.

When an icon looked up in the icon theme was not available, the icon theme may use fallback icons - either those specified to IconTheme.lookup_icon or the always-available "image-missing". The icon chosen is returned by this function.

If the icon was created without an icon theme, this function returns None.

is_symbolic

def is_symbolic(self) -> bool

:::warning Deprecated since 4.20 This API is deprecated. :::

Checks if the icon is symbolic or not.

This currently uses only the file name and not the file contents for determining this. This behaviour may change in the future.

Properties

file

file: Gio.File  # read/write

The file representing the icon, if any.

icon_name

icon_name: str  # read/write

:::warning Deprecated since 4.20 This API is deprecated. :::

The icon name that was chosen during lookup.

is_symbolic

is_symbolic: bool  # read/write

:::warning Deprecated since 4.20 This API is deprecated. :::

Whether the icon is symbolic or not.

scale

scale: int  # read/write

size

size: int  # read/write