Skip to content

pycons

Class info

🛈 DocStrings

Pycons: main package.

Icon utilities (Material Design icons & similar).

get_icon async

get_icon(icon_name: str) -> Icon

Get a font icon, downloading the font on first use.

Parameters:

Name Type Description Default
icon_name str

Name in format "prefix.name" (e.g. "fa.heart")

required

Returns:

Type Description
Icon

Icon with the Unicode character and the path to the font file

Raises:

Type Description
ValueError

If the prefix is unknown or the icon does not exist

Source code in src/pycons/functional.py
async def get_icon(icon_name: str) -> Icon:
    """Get a font icon, downloading the font on first use.

    Args:
        icon_name: Name in format "prefix.name" (e.g. "fa.heart")

    Returns:
        Icon with the Unicode character and the path to the font file

    Raises:
        ValueError: If the prefix is unknown or the icon does not exist
    """
    from pycons.font_providers.registry import FontRegistry

    registry = FontRegistry()
    return await registry.get_icon(icon_name)

get_icon_sync

get_icon_sync(icon_name: str) -> Icon

Synchronous version of get_icon.

Source code in src/pycons/functional.py
def get_icon_sync(icon_name: str) -> Icon:
    """Synchronous version of `get_icon`."""
    return asyncio.run(get_icon(icon_name))