Skip to main content

iconify for python. Universal icon framework

Project description

pyconify

License PyPI Conda Python Version CI codecov

Python wrapper for the Iconify API.

Iconify is a versatile icon framework that includes 100+ icon sets with more than 100,000 icons from FontAwesome, Material Design Icons, DashIcons, Feather Icons, EmojiOne, Noto Emoji and many other open source icon sets.

Search for icons at: https://icon-sets.iconify.design

Installation

pip install pyconify
# or
conda install -c conda-forge pyconify

Usage

import pyconify

# Info on available collections
collections = pyconify.collections()

# Info on specific collection(s)
details = pyconify.collection("fa", "fa-brands")

# Search for icons
hits = pyconify.search("python")

# Get icon data
data = pyconify.icon_data("fa-brands", "python")

# Get SVG
svg = pyconify.svg("fa-brands", "python")

# Get path to SVG on disk
# will either return cached version, or write to temp file
file_name = pyconify.svg_path("fa-brands", "python")

# Get CSS
css = pyconify.css("fa-brands", "python")

# Keywords
pyconify.keywords('home')

# API version
pyconify.iconify_version()

See details for each of these results in the Iconify API documentation.

cache

While the first fetch of any given SVG will require internet access, pyconfiy caches svgs for faster retrieval and offline use. To see or clear cache directory:

import pyconify

# reveal location of cache
# will be ~/.cache/pyconify on linux and macos
# will be %LOCALAPPDATA%\pyconify on windows
# falls back to ~/.pyconify if none of the above are available
pyconify.get_cache_directory()

# remove the cache directory (and all its contents)
pyconify.clear_cache()

If you'd like to precache a number of svgs, the current recommendation is to use the svg() function:

import pyconify

ICONS_TO_STORE = {"mdi:bell", "mdi:bell-off", "mdi:bell-outline"}
for key in ICONS_TO_STORE:
    pyconify.svg(key)

Later calls to svg() will use the cached values.

To specify a custom cache directory, set the PYCONIFY_CACHE environment variable to your desired directory. To disable caching altogether, set the PYCONIFY_CACHE environment variable to false or 0.

freedesktop themes

pyconify includes a convenience function to generate a directory of SVG files in the freedesktop icon theme specification

It takes a mapping of names from the icon naming spec to iconify keys (e.g. "prefix:icon"). Icons will be placed in the appropriate freedesktop subdirectory based on the icon name. Unknown icons will be placed in the other subdirectory.

from pyconify import freedesktop_theme
from pyconify.api import svg
icons = {
    "edit-copy": "ic:sharp-content-copy",
    "edit-delete": {"key": "ic:sharp-delete", "color": "red"},
    "weather-overcast": "ic:sharp-cloud",
    "weather-clear": "ic:sharp-wb-sunny",
    "bell": "bi:bell",
}
folder = freedesktop_theme(
    "mytheme",
    icons,
    base_directory="~/Desktop/icons",
)

would create

~/Desktop/icons/
├── mytheme
│   ├── actions
│   │   ├── edit-copy.svg
│   │   └── edit-delete.svg
│   ├── status
│   │   ├── weather-clear.svg
│   │   └── weather-overcast.svg
│   └── other
│       └── bell.svg
└── index.theme

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyconify-0.2.1.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyconify-0.2.1-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file pyconify-0.2.1.tar.gz.

File metadata

  • Download URL: pyconify-0.2.1.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyconify-0.2.1.tar.gz
Algorithm Hash digest
SHA256 8dd53757d9fbed41711434460932b2b5dbc25da720cd9f9a44af0187b2dfc07d
MD5 06170a7a6eaf02e3306bca7723734367
BLAKE2b-256 fd7f94d424dc756a6287271cf40cf1b2a44c10e3f137bf3246a2b4a7416ca3d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyconify-0.2.1.tar.gz:

Publisher: ci.yml on pyapp-kit/pyconify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyconify-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pyconify-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyconify-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d3b53eee1f8a2d60c1d135610f42e789774dbe71c6d8af68af0a21d3b3ec9eb7
MD5 333c0610f42e864d8069a12ad9856adf
BLAKE2b-256 724050dd2e8bfec81676e4619903bd452c10dc0d8efac1533e79e67cc76759b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyconify-0.2.1-py3-none-any.whl:

Publisher: ci.yml on pyapp-kit/pyconify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page