Gtk.SvgWidget¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Widget (183), GObject.Object (37), Gtk.Accessible (18), Gtk.Buildable (1)
- Structs:
class |
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (7), Gtk.Buildable (9)
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w |
|||
r/w/en |
|||
r/w/en |
|||
r/en |
Signals¶
- Inherited:
Name |
Short Description |
|---|---|
Emitted when a link or other element is activated. |
|
Signals that an error occurred. |
Fields¶
- Inherited:
Class Details¶
- class Gtk.SvgWidget(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A widget that renders SVG, with animations and event handling.
GtkSvgWidgetuses [class`Gtk`.Svg] internally, and should read its documentation to learn about the supported SVG features and extensions.On top of the
GtkSvgrendering,GtkSvgWidgetadds event handling. <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys can be used to move the focus and <kbd>Enter</kbd> and clicks will activate links by emitting the [signal`Gtk`.SvgWidget::activate] signal.The
tabindexandautofocusattributes can be used to influence what elements act as focus locations, and where focus goes initially.The styling of the SVG content is following input-related pseudo classes such as
:focus,:active,:hoveror:visited.If [property`Gtk`.Widget:has-tooltip] is set, then the content of
<title>elements will be shown as tooltips.SVG animations and different ``<view>``s can be triggered by input events as well. The following events are supported: focus, blur, mouseenter, mouseleave, click. See the SVG animation specification for details.
Added in version 4.24.
- classmethod new()[source]¶
- Returns:
the new widget
- Return type:
Creates a new, empty
GtkSvgWidget.Added in version 4.24.
- get_state()[source]¶
- Returns:
the state
- Return type:
Gets the current state of the widget.
Added in version 4.24.
- get_stylesheet()[source]¶
- Returns:
a
GByteswith the CSS data- Return type:
GLib.BytesorNone
Gets the CSS user stylesheet.
Added in version 4.24.
- load_from_bytes(bytes)[source]¶
- Parameters:
bytes (
GLib.Bytes) – the data to data
Loads SVG content into an existing SVG widget.
To track errors while loading SVG content, connect to the [signal`Gtk`.SvgWidget::error] signal.
This clears any previously loaded content.
Added in version 4.24.
- set_state(state)[source]¶
- Parameters:
state (
int) – the state to set, as a value between 0 and 63
Sets the state of the widget.
The state change will apply transitions that are defined in the SVG. See [class`Gtk`.Svg] for details about states and transitions.
Added in version 4.24.
- set_stylesheet(bytes)[source]¶
- Parameters:
bytes (
GLib.BytesorNone) – CSS data
Sets a CSS user stylesheet to use.
Note that styles are applied at load time, so this function must be called before loading SVG.
Added in version 4.24.
Signal Details¶
- Gtk.SvgWidget.signals.activate(svg_widget, id, href)¶
- Signal Name:
activate- Flags:
- Parameters:
svg_widget (
Gtk.SvgWidget) – The object which received the signal
Emitted when a link or other element is activated.
Activating elements can be achieved by clicking or by hitting <kbd>Enter</kbd> while the element has focus.
Added in version 4.24.
- Gtk.SvgWidget.signals.error(svg_widget, error)¶
- Signal Name:
error- Flags:
- Parameters:
svg_widget (
Gtk.SvgWidget) – The object which received the signalerror (
GLib.Error) – the error
Signals that an error occurred.
Errors can occur both during parsing and during rendering.
The expected error values are in the [error`Gtk`.SvgError] enumeration, context information about the location of parsing errors can be obtained with the various
gtk_svg_errorfunctions.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 This signal is emitted in the middle of parsing or rendering, and if you handle it, you must be careful. Logging the errors you receive is fine, but modifying the widget hierarchy or changing the paintable state definitively isn’t.
If in doubt, defer to an idle.
Added in version 4.24.
Property Details¶
- Gtk.SvgWidget.props.resource¶
-
Resource to load SVG data from.
This property is meant for use in ui files.
Added in version 4.24.
- Gtk.SvgWidget.props.state¶
- Name:
state- Type:
- Default Value:
0- Flags:
The current state of the renderer.
This can be a number between 0 and 63.
Added in version 4.24.
- Gtk.SvgWidget.props.stylesheet¶
- Name:
stylesheet- Type:
- Default Value:
- Flags:
A CSS stylesheet to apply to the SVG.
Added in version 4.24.