pop specific event handler?

19 views
Skip to first unread message

Henry Harrison

unread,
Jan 14, 2014, 12:31:16 PM1/14/14
to pyglet...@googlegroups.com
Hi everyone,

I'm a big fan of pyglet, and I'm glad to read hear that it is still under development! I'm not sure I'm experienced enough to contribute, but I will say I've been using the development head for a few projects and haven't run into any bugs.

Anyways, here's my question: is there way to pop a specific handler? I'm using the object-oriented approach suggested in the documentation, with two objects: one that handles all the interactive stuff, and another that just logs every event. I don't want to have to worry about what order I push the handlers on.

More motivation: I'm writing a framework that interfaces the API of some hardware we use in the lab with pyglet. My users aren't really programmers, so I'm trying to make it as simple as possible, and right now I have something like logger.start() and logger.stop() which push and pop handlers. There are several other things client applications will do that push handlers, and the order that these things happen shouldn't matter. The resulting behavior will be very hard to debug especially if I'm completely abstracting away from the stack metaphor. And I do not expect my users to read my documentation!

So in short, I'd really like to be able to do pop_handlers(logger). Is there a way to accomplish this now? Assuming no- is there a structural reason this can't happen? Maybe I could try to patch it in...

"Juan J. Martínez"

unread,
Jan 14, 2014, 4:12:38 PM1/14/14
to pyglet...@googlegroups.com
On 14/01/14 17:31, Henry Harrison wrote:
> [...]
>
> So in short, I'd really like to be able to do pop_handlers(logger). Is
> there a way to accomplish this now? Assuming no- is there a structural
> reason this can't happen? Maybe I could try to patch it in...

I'm not sure if I understand what your want to do, but what about using
remove_handler to implement your pop_handler?

http://pyglet.org/doc-current/api/pyglet/event/pyglet.event.EventDispatcher.html#pyglet.event.EventDispatcher.remove_handler

Regards,

Juan

--
jjm's home: http://www.usebox.net/jjm/
blackshell: http://blackshell.usebox.net/

Henry Harrison

unread,
Jan 14, 2014, 4:20:16 PM1/14/14
to pyglet...@googlegroups.com
Thanks! That's exactly what I wanted. Didn't realize it was already there. Now I feel silly for reading the documentation but not the API reference. Well, thanks again!



--
You received this message because you are subscribed to a topic in the Google Groups "pyglet-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyglet-users/2xqxp_qhyCY/unsubscribe.
To unsubscribe from this group and all its topics, 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.
For more options, visit https://groups.google.com/groups/opt_out.

"Juan J. Martínez"

unread,
Jan 14, 2014, 4:31:34 PM1/14/14
to pyglet...@googlegroups.com
On 14/01/14 21:20, Henry Harrison wrote:
> Thanks! That's exactly what I wanted. Didn't realize it was already
> there. Now I feel silly for reading the documentation but not the API
> reference. Well, thanks again!


Np! Don't be afraid to ask, I had to check the docs myself ;)
Reply all
Reply to author
Forward
0 new messages