edifice.ImageSvg#
- class edifice.ImageSvg(src, **kwargs)[source]#
Bases:
QtWidgetElement[QSvgWidget]Render an SVG image.
Underlying Qt Widget QSvgWidget
Props
All props from
QtWidgetElement, plus:- Parameters:
src (
str|QByteArray) – Either a path to an SVG image file, or a QByteArray containing the XML string of an SVG file.
Usage
Example SVG image constant#henomaru = QByteArray.fromStdString( '<svg viewBox="0 0 200 200"><circle fill="red" cx="100" cy="100" r="100"/></svg>' )
Example ImageSvg#ImageSvg( src=henomaru, style={"width": 100, "height": 100}, )
We can use the
ImageSvgElement to render SVG icons.Find SVG icons on websites like Font Awesome: https://fontawesome.com/
The recommended method is to copy the icon’s SVG code and paste it into a constant
QByteArray.fromStdString()as in the example above. Then pass theQByteArrayto thesrcprop.Or you can download an icon
.svgfile and render the icon by setting thesrcprop to the path of the file.There is also a copy of some Font Awesome icons in the Edifice package, for convenience.
Example Font Awesome Share Icon#ImageSvg( src=str(importlib.resources.files(edifice) / "icons/font-awesome/solid/share.svg"), style={"width": 18, "height": 18 }, )
Methods
__init__(src, **kwargs)register_ref(reference)Registers provided
Referenceto this Element.set_key(key)Set the key of an
Element.Attributes
childrenThe children of this Element.
propsThe props of this Element.
underlyingThe underlying QWidget, which may not exist if this Element has not rendered.