kmonsoor / pyglet

Automatically exported from code.google.com/p/pyglet
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

gdiplus.py : n_delays must be long, not float. #657

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Run examples/animation.py

Paste in the traceback or error message:
Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\pyglet\resource.py", line 538, in animation
    identity = self._cached_animations[name]
  File "C:\Python33\lib\weakref.py", line 69, in __getitem__
    o = self.data[key]()
KeyError: 'dinosaur.gif'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "pyglet-1.2alpha1\examples\programming_guide\animation.py", line 62, in <module>
    animation = pyglet.resource.animation('dinosaur.gif')
  File "C:\Python33\lib\site-packages\pyglet\resource.py", line 540, in animation
    animation = pyglet.image.load_animation(name, self.file(name))
  File "C:\Python33\lib\site-packages\pyglet\image\__init__.py", line 2417, in load_animation
    image = decoder.decode_animation(file, filename)
  File "C:\Python33\lib\site-packages\pyglet\image\codecs\gdiplus.py", line 307, in decode_animation
    delays = cast(prop_item.value, POINTER(c_long * n_delays)).contents
TypeError: can't multiply sequence by non-int of type 'float'
[Finished in 3.0s with exit code 1]

It's just a typecasting issue. TypeError shows line 307 in gdiplus.py
You made a division. Python3 always gives a float after division.
Please change:

n_delays = prop_item.length / sizeof(c_long)  #line 306

into this:

n_delays = prop_item.length // sizeof(c_long) #line 306

There is already a note placed at line 305 : "XXX Sure it's long?"
I'm here to say: "Nope."

and please make a revision to your docs. 'print "something"' is working no 
longer in Python 3.x . It's from 2.x

Original issue reported on code.google.com by nejdetyu...@gmail.com on 27 Jun 2013 at 8:21

GoogleCodeExporter commented 9 years ago
after this I receive:

Traceback (most recent call last):
  File "D:/python/mygame/izom_shooter_v 0.01/test_anim.py", line 8, in <module>
    window = pyglet.window.Window()
  File "C:\Python33\lib\site-packages\pyglet\window\win32\__init__.py", line 131, in __init__
    super(Win32Window, self).__init__(*args, **kwargs)
  File "C:\Python33\lib\site-packages\pyglet\window\__init__.py", line 558, in __init__
    self._create()
  File "C:\Python33\lib\site-packages\pyglet\window\win32\__init__.py", line 261, in _create
    self.context.attach(self.canvas)
  File "C:\Python33\lib\site-packages\pyglet\gl\win32.py", line 263, in attach
    super(Win32ARBContext, self).attach(canvas)
  File "C:\Python33\lib\site-packages\pyglet\gl\win32.py", line 208, in attach
    raise gl.ContextException('Unable to share contexts')
pyglet.gl.ContextException: Unable to share contexts

Original comment by ryhor2...@gmail.com on 29 Aug 2013 at 6:55

GoogleCodeExporter commented 9 years ago
IT DOESNT WORK

import sys

import pyglet
if len(sys.argv) > 1:
    # Load the animation from file path.
    animation = pyglet.image.load_animation(sys.argv[1])
    bin = pyglet.image.atlas.TextureBin()
    animation.add_to_texture_bin(bin)
else:
    # Load animation from resource (this script's directory).
    animation = pyglet.resource.animation('dinosaur.gif')
sprite = pyglet.sprite.Sprite(animation)

window = pyglet.window.Window(width=sprite.width, height=sprite.height)

# Set window background color to white.
pyglet.gl.glClearColor(1, 1, 1, 1)

@window.event
def on_draw():
    window.clear()
    sprite.draw()

pyglet.app.run()

IT WORKS

import sys
import pyglet
window = pyglet.window.Window()
if len(sys.argv) > 1:
    # Load the animation from file path.
    animation = pyglet.image.load_animation(sys.argv[1])
    bin = pyglet.image.atlas.TextureBin()
    animation.add_to_texture_bin(bin)
else:
    # Load animation from resource (this script's directory).
    animation = pyglet.resource.animation('dinosaur.gif')
sprite = pyglet.sprite.Sprite(animation)

#window = pyglet.window.Window(width=sprite.width, height=sprite.height)

# Set window background color to white.
pyglet.gl.glClearColor(1, 1, 1, 1)

@window.event
def on_draw():
    window.clear()
    sprite.draw()

pyglet.app.run()

Original comment by ryhor2...@gmail.com on 29 Aug 2013 at 7:43

GoogleCodeExporter commented 9 years ago
That is another issue I think. Maybe you wish to make another thread for it.

Original comment by nejdetyu...@gmail.com on 29 Aug 2013 at 7:49

GoogleCodeExporter commented 9 years ago
This issue was closed by revision baae6642b575.

Original comment by useboxnet on 21 Sep 2013 at 9:51

GoogleCodeExporter commented 9 years ago
Please open a new issue for what you commented on #1.

Thanks a lot for your patch!

Original comment by useboxnet on 21 Sep 2013 at 9:52

GoogleCodeExporter commented 9 years ago
Issue 601 has been merged into this issue.

Original comment by useboxnet on 1 Dec 2013 at 9:00