Larry Keber
unread,Mar 16, 2008, 1:30:31 PM3/16/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pyglet-users
Hi,
I attended the talk on pyglet here at PyCon yesterday and was very
impressed. I've been playing with it since.
I'd like to build sprite images (using PIL, although if there is a
better way I'd be glad to use it). Then, I'd like to instantiate
pyglet Sprites using the generated image data. I'm having trouble
getting it to work:
## using PIL 1.1.6 and pyglet 1.1alpha1
import pyglet
from pyglet.sprite import Sprite
from pyglet.image import ImageData
import Image, ImageDraw
pim = Image.new('RGB', (50, 50))
draw = ImageDraw.Draw(pim)
draw.ellipse((0, 0, 49, 49))
draw.text((0, 10), "sprite1")
pim.save('sprite1.jpg')
## I've tried both of the following variations
bdata = list(pim.getdata())
#bdata =
pim.getdata()
## I've tried this:
#img = pyglet.image.create(50,
50)
#img.set_data('RGB', 50,
bdata)
## and this:
img = ImageData(50, 50, 'RGB', bdata)
p = Sprite(img)
############# end of code
I always receive the following error. Am I doing something wrong and/
or stupid? Thanks for any help. -- Larry
lak@Argent:~/python/testpyglet $ python test.py
Traceback (most recent call last):
File "test.py", line 20, in <module>
p = Sprite(img)
File "build/bdist.linux-x86_64/egg/pyglet/sprite.py", line 210, in
__init__
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/PIL/__init__.py", line 780, in get_texture
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/PIL/__init__.py", line 774, in create_texture
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/PIL/__init__.py", line 948, in blit_to_texture
ctypes.ArgumentError: argument 9: <type 'exceptions.TypeError'>: wrong
type
Exception exceptions.AttributeError: "'Sprite' object has no attribute
'_vertex_list'" in <bound method Sprite.__del__ of
<pyglet.sprite.Sprite object at 0x15aef490>> ignored
lak@Argent:~/python/testpyglet $