pygame is
Simple DirectMedia Layer is
Site Swing
Tiled TMX Loader

Tiled TMX Loader - v.13

Leif Theden (bitcraft)



Map loader for TMX Files
Leif Theden (bitcraft), 2011-2014
v3.19.3 - for python 2.7 and 3.3+

If you have any problems or suggestions, please open an issue on the github page.
I am also often lurking #pygame on freenode. Feel free to contact me.

released under the LGPL v3


PyTMX is a map loader for python/pygame designed for games. It provides smart
tile loading with a fast and efficient storage base. Not only will does it
correctly handle most Tiled object types, it also will load metadata for
them, so you can modify your maps and objects in Tiled, instead of modifying
your source code.

    API with many handy functions
    Properties metadata for all native Tiled object types
    Point data for polygon and polyline objects
    Automatic flipping and rotation of tiles
    Supports base64, csv, gzip, zlib and uncompressed XML
    Image loading with pygame (works ok without pygame)


Just data

    >>> import pytmx
    >>> tmxdata = pytmx.TiledMap("map.tmx")

Load with Pygame Surfaces

    >>> from pytmx import load_pygame
    >>> tmxdata = load_pygame("map.tmx")

The loader will correctly convert() or convert_alpha() each tile image, so you
don't have to worry about that after you load the map.

Getting the Tile Surface

    >>> image = tmx_data.get_tile_image(x, y, layer)
    >>> screen.blit(image, position)

Getting Object Properties
    >>> tmxdata = TiledMap('level1.tmx')
    >>> props = txmdata.get_tile_properties(x, y, layer)
    >>> props = tmxdata.get_layer_by_name("dirt").properties

Using Raw XML

It is possible to load TiledMap object from XML strings.

    >>> tmxdata = TiledMap.from_string(xml_string)


I have another repo with a working demo of a proper scrolling map using Tiled
maps. Please feel free to test drive it. It isn't limited to Tiled maps,
you can use any data structure you want, as long as PyGame is used.


The 16x16 overworld tiles were created by MrBeast at CC-BY 3.0


Lots of internal changes and performance fixes.

See changelog in readme.


Home Page:


click to view original size


Tiled TMX Loader - 3.19.3 - Sep 17, 2014
Tiled TMX Loader - v.15 - May 31, 2012
Tiled TMX Loader - v.14 - May 10, 2012
Tiled TMX Loader - v.13 - Mar 20, 2012
Tiled TMX Loader - v.11 - Feb 20, 2012 account Comments

If you wish to leave a comment with your account, please sign in first.

December 8, 2011 10:50pm - Leif Theden - nickname: (bitcraft)
milleja46: i cannot test this on python 3.x.
November 15, 2011 2:48pm - Josh Miller - nickname: (milleja46)
Still doesn't work...the import of it works fine.
The problem is doing "tiledmap = tmxloader.load_pygame("test.tmx")" it reports a error with str and bytes which shouldn't happen since test.tmx is a filename...(this is the python 3 version you gave me)
November 1, 2011 3:13pm - Leif Theden - nickname: (bitcraft)
@milleja46 I am not able to reproduce this, but I realize what caused it. I'll have a fixed version up soon. Thanks for the report.
October 31, 2011 10:15am - Josh Miller - nickname: (milleja46) - 2/5
I try and run it and i get:
"Traceback (most recent call last):
File "E:\Documents\gameEngine\", line 5, in <module>
import tmxloader
File "E:\Documents\gameEngine\", line 136
except IndexError, ValueError:
SyntaxError: invalid syntax"

So it doesn't work and i've not even tried using a map made in tiled o_o

our projects welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
recent releases
Feb 21, 2017

Jan 31, 2017

Jan 24, 2017

Jan 18, 2017

Jan 7, 2017

Dec 30, 2016

Dec 8, 2016

Nov 28, 2016

Nov 27, 2016

... more!
for pygame related questions, comments, and suggestions, please see help (lists, irc)