Skip to main content

A Python library/utility to create CSS sprites.

This library was made out of my frustration to be unable to find a library that suited exactly what I had in mind. And also because I found the idea of writing that quite fun :)

Now a first version is done, I don’t know if I’m going to push the development further. Don’t use this in production, unless you are ready to dig into the code and maintain the app yourself.

Usage

PTL source file

Everything is generated from the PTL source file. It has a few options:

[css]
# The prefix that will be put in front of every generated CSS selector.
# The selectors are generated from the file names. With the current
# configuration, what you'd get for a toto.png file would be a
# .icon-toto class.
prefix = .icon-

# This is a selector of the global class for all generated tiles (it
# sets some styles attributes for everybody)
general_selector = [class^="icon-"], [class*=" icon-"]

[sprite]
# A hint of the number of tiles that fits in the width of the sprite.
width = 15

# The relative path from the generated CSS file to the generated sprite
# file. This sprite file will be generated at compilation time.
filename = sprite.png

# A valid PIL format name
format = PNG

[tile]
# This is a hint about the tiles size. Put here your most common tile
# size, or the LCM of your tiles sizes, or something in that mood.
width = 16
height = 16

[files]
# Here goes a plain glob list of files to be put in the sprite. The
# path is relative to the .ptl file.
sprite/*.png

CLI Tool

Once you have the PTL source, compiling is quite simple:

ponytile input.ptl output.css

It will generate the output.css file with the appropriate sprite file as configured by the PTL file.

Using in your web page

Just include the generated CSS somewhere, and then do:

<i class="icon-toto"></i>

It should make the trick :)

Using the library

Open bin/ponytile and look at how things are done. There is not much more to say about the public API right now!

Metadata

Release files for Ponytile 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Ponytile 0.1.1
File Size Uploaded Provenance
Ponytile-0.1.1.tar.gz 7.0 kB Without provenance Details

Release files / Ponytile-0.1.1.tar.gz

Download URL Ponytile-0.1.1.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
eeed7b6816b3e70650ad8b33f5776d7e8f1bfddadfdeef21cf9b2bceacc65dc6
BLAKE2b-256 checksum
How to use checksums
d281c49b5d83d721849209618e4e13d3f8611e520ce48c47afd45d00085a6265
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for Ponytile 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page