flet-svg
A Flet extension to render SVG with flutter_svg.
Installation
Add dependency to pyproject.toml of your Flet app:
- Git dependency
Link to git repository:
dependencies = [
"flet-svg @ git+https://github.com/yoshoku/flet-svg",
"flet>=0.28.3",
]
- PyPi dependency
If the package is published on pypi.org:
dependencies = [
"flet-svg",
"flet>=0.28.3",
]
Build your app:
flet build <target> -v
Basic Usage
Here is an example of displaying an SVG string:
import flet as ft
from flet_svg import FletSvg
def main(page: ft.Page):
page.vertical_alignment = ft.MainAxisAlignment.CENTER
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.add(FletSvg(
src='<svg xmlns="http://www.w3.org/2000/svg" width="240" height="240">'
'<rect x="30" y="30" width="120" height="120" rx="10" fill="rgb(219, 15, 73)"/>'
'<rect x="90" y="90" width="120" height="120" rx="10" fill="rgb(0, 141, 251)" fill-opacity="0.5"/>'
'</svg>',
kind='string'
))
ft.app(main)
Below is an example of displaying an SVG file on the network. This SVG is the one used in the tutorial on creating Solitaire game with Flet:
import flet as ft
from flet_svg import FletSvg
def main(page: ft.Page):
page.vertical_alignment = ft.MainAxisAlignment.CENTER
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.add(FletSvg(
src='https://raw.githubusercontent.com/flet-dev/'
'examples/refs/heads/main/python/tutorials/solitaire/'
'solitaire-game-rules/assets/images/King_clubs.svg',
kind='network'
))
ft.app(main)
Properties
flet-svg's properties correspond to the properties of SvgPicture class.
src(str): The source of the SVG image.kind(str): The constructor to call. 'string', 'network', 'assets', 'file', or 'memory'. The default is'string'.key(str)fit(str): 'contain', 'fit', 'cover', 'fit_width', 'fit_height', 'none', or 'scale_down', The default is'contain'.alignment(str): 'center', 'bottom_right', 'bottom_center', 'bottom_left', 'top_right', 'top_center', or 'top_left'. The default is'center'.width(number):height(number):match_text_direction(bool): The default isfalse.allow_drawing_outside_view_box(bool): The default isfalse.semantics_label(str):exclude_from_semantics(bool): The default isfalse.clip_behavior(str): 'hard_edge', 'none', 'anti_alias', or 'anti_alias_with_save_layer'. The default is'hard_edge'
Metadata
Release files for flet-svg 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flet_svg-0.1.0.tar.gz | 12.0 kB | Without provenance | Details for flet_svg-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flet_svg-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for flet_svg-0.1.0-py3-none-any.whl |
Total release size: 24.8 kB
Release files / flet_svg-0.1.0.tar.gz
| Download URL | flet_svg-0.1.0.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fcdd28ca3d00d87d08a5ec6f881e19be407805438133efbdaa2f65a95d62b186
|
|
BLAKE2b-256 checksum How to use checksums |
283e3a3d480336bf1da9d40afaf0b61e14bf8e47a5aa82b5b8d177842174235a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Release files / flet_svg-0.1.0-py3-none-any.whl
| Download URL | flet_svg-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c3cbddee4320b5d317f2aee614b4fdfa347e1d87894ec54f59a776e4485bae58
|
|
BLAKE2b-256 checksum How to use checksums |
f1be58a48797ca65b29c72fb87b02173ed8f5aec7d43f224b0439b780e6eacbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Security for flet-svg 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.