Skip to main content

A short description of your package

Project description

PyCheese

PyCheese is a Python-based tool for generating beautiful, high-quality images of code with syntax highlighting, rendered in a macOS-style terminal window. Built for automation and easy customization, it can be easily integrated into scripts or pipelines.

example-image


Features

  • Syntax Highlighting – Utilizes Pygments with support for dozens of languages.
  • macOS-style Terminal UI – Recreates the terminal header and shadow.
  • Fonts – Use any TTF font, comes with JetBrains Mono for elegant, readable code.
  • Fully Scriptable – Designed to run headlessly from scripts, CI pipelines, or other Python apps.
  • Easily Customizable – Modify themes, fonts, window styles, and more in plain Python.
  • Self-contained – No need for browsers or servers. Everything runs locally.

Installation

pip install pycheese

Command Line Usage

Render the code in test.py in a default 80x24 window. By default, the window scrolls with the code and only the last 24 rows will be shown if the code does not fit into the window.

python pycheese.py test.py

Use the --columns and --rows options to extend the window.

python pycheese.py test.py --rows 40

Programmatic Usage

from pycheese import PyCheese, PyCheeseConfig

tool = PyCheese()
tool.render_code_to_file(
    code='print("Hello, world!")',
    output_path='hello_world.png'
)

A slightly more custom way to call the tool is to create a RenderConfig to overwrite specific parameters.

config = PyCheeseConfig(
    shadow_offset = 20,
    shadow_blur = 3,
    shadow_color = "purple",
    shadow_alpha = 220,
)
renderer = PyCheese(
    code='print("Hello, world!")',
    config=config,
)
renderer.render()  # render all layers
renderer.final_image.show()  # access PIL image object

PyCheese renders four distinct layers: background, shadow, text, and title bar. They are composited into the final image. This approach allows the modification of individual layers for an animation without having to re-render any other layers.

renderer.bg_layer
renderer.shadow_layer
renderer.text_layer
renderer.titlebar_layer
renderer.final_image

It's possible to efficiently generate an animation by only modifying the layer that is changing.

code='print("Hello, world!")',
for style in ["monokai", ""]:
    renderer.render_text_layer(code=code, style=style)
    renderer.render()
    renderer.final_image.show()
    print(color)

Fonts

The tool comes with the JetBrainsMono font. Direct the tool to your fonts folder for more font choices.

Styles

PyCheese uses the Pygments library which comes with a range of styles that can be selected with the --style options. The complete list can be found here.

Some dark styles:

  • monokai
  • zenburn
  • nord
  • dracula
  • gruvbox-dark

Some light styles:

  • solarized-light
  • gruvbox-light
  • friendly
  • friendly_grayscale
  • murphy

Alternatives

Font License

JetBrains Mono typeface is available under the OFL-1.1 License and can be used free of charge, for both commercial and non-commercial purposes. You do not need to give credit to JetBrains, although we will appreciate it very much if you do. See JetBrainsMono License

License

With the exception of the font files, the code and assets contained in this repository are licensed under GNU General Public License v3.0 as detailed in the LICENSE file.

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

pycheese-0.1.0.tar.gz (559.0 kB view details)

Uploaded Source

Built Distribution

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

pycheese-0.1.0-py3-none-any.whl (556.8 kB view details)

Uploaded Python 3

File details

Details for the file pycheese-0.1.0.tar.gz.

File metadata

  • Download URL: pycheese-0.1.0.tar.gz
  • Upload date:
  • Size: 559.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for pycheese-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c8ac79167833875ff0238979c2fb858900bc1a0725385b87c32f1f52b9353f4
MD5 8ae13a7faea1a2c1737e4478feb6bd5c
BLAKE2b-256 eb75cacbd5087970424b8315c553f6ec920c84cc42ce2e423d686ec5edb0104f

See more details on using hashes here.

File details

Details for the file pycheese-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pycheese-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 556.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for pycheese-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb0bf31e4abaebf5987ef43eca8abbab142f5b79849590dc08bf496a174e617b
MD5 285a7b9cc95791b92cf63bd538eb42ff
BLAKE2b-256 3a1b3a625e9c99a01649d994f67432bc050c8ae2710b2dd746b83f6b54270041

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