:right-sidebar: True Svg =================================================================== .. currentmodule:: gi.repository.Gtk .. versionadded:: 4.22 .. class:: Svg(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gdk.Paintable`, :class:`~gi.repository.Gtk.SymbolicPaintable` A paintable implementation that renders SVG, with animations. ``GtkSvg`` objects are created by parsing a subset of SVG, including SVG animations. ``GtkSvg`` fills or strokes paths with symbolic or fixed colors. It can have multiple states, and paths can be included in a subset of the states. States can have animations, and the transition between different states can also be animated. To show a static SVG image, it is enough to load the the SVG and use it like any other paintable. To play an SVG animation, use :obj:`~gi.repository.Gtk.Svg.set_frame_clock` to connect the paintable to a frame clock, and call :obj:`~gi.repository.Gtk.Svg.play` after loading the SVG. The animation can be paused using :obj:`~gi.repository.Gtk.Svg.pause`\. To set the current state, use :obj:`~gi.repository.Gtk.Svg.set_state`\. Error handling -------------------------------------------------------------------------------- Loading an SVG into ``GtkSvg`` will always produce a (possibly empty) paintable. GTK will drop things that it can't handle and try to make sense of the rest. To track errors during parsing or rendering, connect to the :obj:`~gi.repository.Gtk.Svg.signals.error` signal. For parsing errors in the ``GTK_SVG_ERROR`` domain, the functions :obj:`~gi.repository.Gtk.SvgError.get_start`\, :obj:`~gi.repository.Gtk.SvgError.get_end`\, :obj:`~gi.repository.Gtk.SvgError.get_element` and :obj:`~gi.repository.Gtk.SvgError.get_attribute` can be used to obtain information about where the error occurred. The supported subset of SVG -------------------------------------------------------------------------------- The paintable supports much of SVG 2, with some exceptions. Among the graphical elements, ```` and ```` are not supported. Among the structural elements, ```` and ```` are not supported. In the ```` element, the following primitives are not supported: feConvolveMatrix, feDiffuseLighting, feMorphology, feSpecularLighting and feTurbulence. Support for the ``mask`` attribute is limited to just a url referring to the ```` element by ID. In animation elements, the parsing of ``begin`` and ``end`` attributes is limited, and the ``min`` and ``max`` attributes are not supported. Lastly, there is only minimal CSS support (the style attribute, but not ``