Skip to main content

Use any of the 2k+ free FontAwesome icons in your tkinter application.

Project description

GitHub issues License

CTkFontAwesome

Requires Python 3.8+

CTkFontAwesome is a maintained continuation and repackaging of the original TkFontAwesome project by Israel Dryer.

A library that enables you to use FontAwesome icons in your CustomTkinter / Tkinter application.

You may use any of the 2k+ free FontAwesome 6.5 icons. The fill color and size are customized to your specifications and then converted to an object via an optional image backend based on CairoSVG and Pillow that can be used anywhere you would use a tkinter.PhotoImage object.

example-2

Installation

python -m pip install ctkfontawesome

This installs the icon database and SVG lookup helpers without any native or compiled dependencies.

If you also want icon_to_image() or icon_to_ctkimage(), install the optional image dependencies:

python -m pip install "ctkfontawesome[images]"

This installs CairoSVG, Pillow, and CustomTkinter for SVG rasterization and image support.

Icon Browser

CTkFontAwesome includes an installable icon browser for searching the bundled Font Awesome set, previewing icons, and copying ready-to-use CustomTkinter code.

ctkfontawesome-browser

The browser itself is included in the base install, but live image previews require the optional image dependencies:

python -m pip install "ctkfontawesome[images]"

CTkFontAwesome browser

Development

This repository now supports a Poetry-based development workflow.

poetry install

To install the optional image backend in the Poetry environment:

poetry install --extras images

To run the icon browser during development:

poetry run ctkfontawesome-browser

To bump the package version and create a git commit and tag:

poetry run bump2version patch

Use minor or major instead of patch when appropriate. The bump updates both pyproject.toml and ctkfontawesome/__init__.py.

Once installed, you can launch the browser with:

ctkfontawesome-browser

Usage

import tkinter as tk
from ctkfontawesome import icon_to_image

root = tk.Tk()
fb = icon_to_image("facebook", fill="#4267B2", scale_to_width=64)
send = icon_to_image("paper-plane", fill="#1D9F75", scale_to_width=64)

tk.Label(root, image=fb).pack(padx=10, pady=10)
tk.Button(root, image=send).pack(padx=10, pady=10)

root.mainloop()

CustomTkinter Usage

import customtkinter as ctk
from ctkfontawesome import icon_to_ctkimage

app = ctk.CTk()
icon = icon_to_ctkimage("eye", fill="#1D9F75", scale_to_width=28)

button = ctk.CTkButton(app, text="Preview", image=icon, compound="left")
button.pack(padx=20, pady=20)

app.mainloop()

Usage Without Image Dependencies

from ctkfontawesome import icon_to_svg

svg = icon_to_svg("facebook")
print(svg[:80])

example-1

API: icon_to_image()

(
    name=None,
    fill=None,
    scale_to_width=None,
    scale_to_height=None,
    scale=1
)

Parameters

Name Type Description Default
name str The name of the FontAwesome icon. None
fill str The fill color of the svg path. None
scale_to_width int Adjust image width to this size (in pixels); maintains aspect ratio. None
scale_to_height int Adjust image height to this size (in pixels); maintains aspect ratio. None
scale float Scale the image width and height by this factor. 1

API: icon_to_ctkimage()

Same parameters as icon_to_image(), but returns a customtkinter.CTkImage for DPI-aware use in CustomTkinter widgets. This API requires the ctkfontawesome[images] optional dependencies.

API: icon_to_svg()

Returns the raw SVG XML string for the requested icon name.

License

The CC BY 4.0 license applies to all FontAwesome free icons used in the library. The MIT License applies to all other work.


Maintainer: Clive Bostock Original project concept and implementation by Israel Dryer 📦 Available on PyPI | 🐙 GitHub

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

ctkfontawesome-0.5.0.tar.gz (482.0 kB view details)

Uploaded Source

Built Distribution

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

ctkfontawesome-0.5.0-py3-none-any.whl (482.4 kB view details)

Uploaded Python 3

File details

Details for the file ctkfontawesome-0.5.0.tar.gz.

File metadata

  • Download URL: ctkfontawesome-0.5.0.tar.gz
  • Upload date:
  • Size: 482.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.10.14 Linux/6.8.0-63-generic

File hashes

Hashes for ctkfontawesome-0.5.0.tar.gz
Algorithm Hash digest
SHA256 812c6d4dea2a8920efc67f530550d0ab75bb2cb8d843d4c0bef9796b5f88cb8a
MD5 21878219c6e597dd788c8ad79da213f9
BLAKE2b-256 2aada3b4f1350b63378f9e7e497aaeb364c9bb3142511a325a13eb0e7c88edc7

See more details on using hashes here.

File details

Details for the file ctkfontawesome-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: ctkfontawesome-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 482.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.10.14 Linux/6.8.0-63-generic

File hashes

Hashes for ctkfontawesome-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 449a6bcb2fe32175bba19d2075077402c7d0cdd0e8d12d6c43958e50b05bc8e5
MD5 782d304f89e71871f519158f60bfdfd9
BLAKE2b-256 f65567f7872ab48a085c29e8439469d3b71cb724afb0e807146e81c6ccfcd0e1

See more details on using hashes here.

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