Re: error trying to load sprites

44 views
Skip to first unread message

Linus Heckemann

unread,
May 28, 2013, 5:20:42 PM5/28/13
to pyglet...@googlegroups.com

Python 3 broke reverse compatibility to 2.x versions. I'm not sure, but it's likely that pyglet simply doesn't work on Python 3.x.

On 17 May 2013 06:53, "Paul Pittlerson" <menko...@gmail.com> wrote:
I'm trying to learn pyglet, and have installed 1.2alpha with python3.3.2 64bit edition.

I have a simple script for loading an image form a sprite sheet and displaying it as a large map.

class grid(pyglet.image.ImageGrid):
    def __init__(self, sprite):
        super(grid, self).__init__(sprite, 3, 1, 96, 96)

class map_tile(pyglet.sprite.Sprite):
    def __init__(self, file):
        super(map_tile, self).__init__(pyglet.resource.image(file))
    
class screen(pyglet.window.Window):
    def __init__(self, w, h):
        super(screen, self).__init__(w, h)
        self.clock = pyglet.clock.ClockDisplay()
        pyglet.clock.schedule_interval(self.update, 1/60.)
        
        raw = pyglet.image.load('images/map_sprites.png')
        raw_seq = pyglet.image.ImageGrid(raw, 3, 1, 96, 96)
        
        self.batch = pyglet.graphics.Batch()
        self.collection = []
        x, y = 0, 0
        
        for i in range(100):
            for j in range(100):
                sprite = pyglet.sprite.Sprite(raw_seq[2], batch = self.batch)
                sprite.x = x
                sprite.y = y
                self.collection.append(sprite)
                x += 96
            y += 96
            x = 0
        
    def update(self, dt):
        pass
        
    def on_draw(self):
        self.clear()
        self.batch.draw()
        self.clock.draw()
        pyglet.clock.tick()

if __name__ == '__main__':
    s = screen(1600, 900)
    pyglet.app.run()

However, when trying to run this, I get the following error:
Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\pyglet\__init__.py", line 332, in __getattr__
    return getattr(self._module, name)
AttributeError: 'NoneType' object has no attribute 'ImageGrid'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Pittler\Desktop\Dev\extra\pyglet experimentation\bullet_client.py", line 12, in <module>
    class grid(pyglet.image.ImageGrid):
  File "C:\Python33\lib\site-packages\pyglet\__init__.py", line 338, in __getattr__
    __import__(import_name)
  File "C:\Python33\lib\site-packages\pyglet\image\__init__.py", line 189
    except codecs.ImageDecodeException, e:
                                      ^
SyntaxError: invalid syntax

The program worked fine in python2.7 32bit, but now it's not working. What might the problem be and how do I fix it?

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users...@googlegroups.com.
To post to this group, send email to pyglet...@googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Tristam MacDonald

unread,
May 28, 2013, 5:29:17 PM5/28/13
to pyglet-users
On Tue, May 28, 2013 at 5:20 PM, Linus Heckemann <li...@soundray.de> wrote:

Python 3 broke reverse compatibility to 2.x versions. I'm not sure, but it's likely that pyglet simply doesn't work on Python 3.x.


I believe it mostly does work, provided you run it through the 2to3 tool. Someone else around here should know for sure, though...

--
Tristam MacDonald
Software Development Engineer, Amazon.com

Andre D

unread,
May 28, 2013, 9:19:21 PM5/28/13
to pyglet...@googlegroups.com
Trunk supports it via 2to3 with manual work which went into making it work the rest of the way.  If you run setup.py build in python3 with your build dir deleted, it should do the rest for you.


--

Anna Mária Nagy

unread,
May 29, 2013, 6:40:52 AM5/29/13
to pyglet...@googlegroups.com

Anna Mária Nagy

unread,
May 29, 2013, 6:41:13 AM5/29/13
to pyglet...@googlegroups.com
On Tue, May 28, 2013 at 11:20 PM, Linus Heckemann <li...@soundray.de> wrote:
> Python 3 broke reverse compatibility to 2.x versions. I'm not sure, but it's
> likely that pyglet simply doesn't work on Python 3.x.
>
Reply all
Reply to author
Forward
0 new messages