Another Python library for TMX

Just want to share this:

https://pypi.python.org/pypi/tmx

I was unsatisfied with PyTMX. I found it overly complex. So, I wrote a much simpler TMX library for Python. It doesn’t try to integrate into any particular library or hold your hand with high-level functions; it just gives you the data from the TMX so you can choose what you want to do with it.

If you needed to integrate TMX with some Python project, you may find this useful, as it takes care of all of the XML parsing and whatnot. It’s under the Apache License.

Documentation is here:

http://pythonhosted.org/tmx

Since you only mention PyTMX, did you not try pytmxlib? It sounds better suitable for your use-case.

Feel free to add your library to this list if you believe it will be more useful for some people.

What I don’t understand from the documentation of your library, is how you are preserving the layer order. I only see three separate containers for image layers, tile layers and object layers, so how do you determine in which order to save those?

Hm, nope, I didn’t notice tmxlib. Not sure how I missed it. That seems perfect. I’ve decided to delete mine from PyPI to avoid potential confusion.

About layers: I didn’t realize that was an issue. Perhaps the page describing the TMX format should mention that the order of tile layers and object layers matters and that they’re both a part of the same list.

I’m glad to hear pytmxlib suits your needs as well!

Alright, I’ve added the following note to the TMX Map Format page:

“A map contains three different kinds of layers. Tile layers were once the only type, and are simply called layer, object layers have the objectgroup tag and image layers use the imagelayer tag. The order in which these layers appear is the order in which the layers are rendered by Tiled.”

I already noticed another TMX library, tmxparser, also doesn’t maintain the layer order. I’ve opened an issue about this.

I’ve decided I’m going to maintain this library after all. tmxlib is good, but I think my implementation is slightly better, and documented better.

So, I’ve fixed the problem in tmx; ordering of layers is now preserved. This was as simple as combining the different types of layers into one list, rather than giving each their own separate list.