Code Monkey home page Code Monkey logo

tkfontawesome's Introduction

TkFontAwesome

A library that enables you to use FontAwesome icons in your tkinter application.

You may use any of the 1k+ free FontAwesome 5.0 icons. The fill color and size are customized to your specifications and then converted to an object via tksvg that can be used anywhere you would use a tkinter.PhotoImage object.

example-2

Installation

python -m pip install tkfontawesome

Usage

import tkinter as tk
from tkfontawesome 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()

example-1

tkfontawesome.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

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.

tkfontawesome's People

Contributors

israel-dryer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tkfontawesome's Issues

How to scale automatically an icon when the display settings changes?

it's not a real issue but, is there a way to scale automatically an icon put a tk button/label widget when the display settings changes? it already happens for the other tk widgets. for example, the text placed in a tk label, changes its resolution automatically, but an SVG icon placed in same widget or in another one no, and the function "svg_to_image" just allow you to specify a specific scale value, so how can I solve this issue?

No such file or directory: 'pacman'

On mac os i tried to install this package using command pip install fontawesome but it give me error.

Collecting tkfontawesome
Using cached tkfontawesome-0.2.0-py3-none-any.whl (405 kB)
Collecting tksvg==0.7.4
Using cached tksvg-0.7.4.tar.gz (50 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [12 lines of output]
Installing dependency cmake... Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "/private/var/folders/p2/_8dlzbbd3kq5wr0rmwd2xh600000gn/T/pip-install-qez1bb0p/tksvg_a96fbe2637684b8398caee99455febb7/setup.py", line 62, in
sp.call(["pacman", "--needed", "--noconfirm", "-S", "mingw-w64-x86_64-{}".format(dep)]) # , stdout=sp.PIPE)
File "/usr/local/Cellar/[email protected]/3.9.12_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 349, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/local/Cellar/[email protected]/3.9.12_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/local/Cellar/[email protected]/3.9.12_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'pacman'
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

Update Needed for Python3.11

It seems that tkfontawesome fails to install in PyCharm when using Python3.11. tkfontawesome requires lxml4.7 which is only available for Python3.10 and earlier. Do you plan on updating tkfontawesome for Python3.11 using lxml4.9?

Can't seem to install this library anymore

Hi @israel-dryer. I get this when trying to install via PyCharm:


Collecting tkfontawesome
  Using cached tkfontawesome-0.2.0-py3-none-any.whl (405 kB)
Collecting lxml==4.7.1 (from tkfontawesome)
  Using cached lxml-4.7.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (6.9 MB)
Collecting tksvg==0.7.4 (from tkfontawesome)
  Using cached tksvg-0.7.4.tar.gz (50 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'

  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      scikit-build is required to build this project
      install with `python -m pip install scikit-build`
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-jr4vv2q1/tksvg_afc2a3ceb73d44ea9268c70b9d76a4bb/setup.py", line 28, in <module>
          from skbuild import setup
      ModuleNotFoundError: No module named 'skbuild'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I am on Linux Mint 21.1 (which is based on Ubuntu).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.