pyglet, i don't understand why this code isn't working

songbird songbird at anthive.com
Fri Nov 2 15:58:25 EDT 2018


  hello,  :)

  my question is below, a bit of background first.
i'm very new to python and picking it up by working
on a project for fun.

  please don't critique my style or lack of
classes/objects in the code yet - i'm way too new.  :)


  my current project is at:

  https://salsa.debian.org/ant-guest/gfpoken-in-python/
  https://salsa.debian.org/ant-guest/gfpoken-in-python/tree/next

  i'm using pyglet (most recent version) and gtk...
in Debian Linux testing.

  my question is that in on_animation_end in the my_sprite.py
class doesn't seem to work as i'd expect.

  i never reach:   print ("Do we Ever get here?") statement.

  and i'm curious if i've just messed up something obvious
here or if my problem is elsewhere?

  i don't really quite understand subclasses/super yet so
perhaps i've abused it?

  the overall issue is that i'm trying to turn off and on
the animation and while i can do it in code like below i
haven't yet been able to figure out how to get that into
my other code...

  thanks for your input/consideration.  :)

  p.s. if you don't know the game gfpoken it is in 
debian/linux and it is a mirror puzzle game.  the
man page is there.  i haven't written help screen or
directions yet, but you click on things to the right
and place them on the grid on the left until the output
of the animation matches the colored arrows.

  it is mostly done other than some directions, checking
the boards for matching/winning, winning game screen and 
help.  just trying to iron this issue out...


=====
import pyglet

marble_roll_image = pyglet.image.load('green_marbles.png')
marble_seq = pyglet.image.ImageGrid(marble_roll_image, 1, 16)
anim = pyglet.image.Animation.from_image_sequence(marble_seq, 0.1, True)
marble_anim_sprite = pyglet.sprite.Sprite(anim)

window = pyglet.window.Window()

def test_off (dt, sprite):
    pyglet.clock.unschedule(sprite._animate)

def test_on (dt, sprite):
    pyglet.clock.schedule(sprite._animate)


pyglet.clock.schedule_once(test_off, 5, marble_anim_sprite)
pyglet.clock.schedule_once(test_on, 10, marble_anim_sprite)


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


@marble_anim_sprite.event
def on_animation_end ():

    print ("on_animation_end ")


pyglet.app.run()
=====


  songbird



More information about the Python-list mailing list