Hello,
I was sold on pyglet because of this exact fact.
Pyglet is instant recognition of your key presses. There is no loop like
pygame has. It would be not unlike if you put a while loop checking for
events in one thread and the tick in another thread. Also, pyglet is
much higher level than pygame. The EventDispatcher has all types of events.
I don't know where there is a list of all events, but to add an event,
you do:
import pyglet
window = pyglet.window.Window(caption="My test app")
k = pyglet.window.key
#Without the shortcut
def on_key_press(key, mods):
if key == k.SPACE:
print("Hello world")
window.set_handlers(on_key_press)
pygame.app.run()
There is a shortcut (By a little bit but is not explicit like this is)
@window.event
def on_key_press(key, mods):
...
Hope this helps.
Thanks,
Brandon Keith Biggs <http://www.brandonkeithbiggs.com/>
On 3/10/2015 12:32 PM, Jose Luis Da wrote:
Hi all,
I do not understand completely how to use pyglet's event system. What
I need to do is to get each event for each frame. In Pygame I can do
it in the following way:
import sys, pygame
pygame.init()
size = width, height = 320, 240
screen = pygame.display.set_mode(size)
while 1:
for event in pygame.event.get():
print event
if event.type == pygame.QUIT: sys.exit()
screen.fill((0,0,0))
pygame.display.flip()
I accomplish something similar with pyglet, using
'pyglet.window.event.WindowEventLogger()' but I do not how to acces to
the information that the WindowEventLogger prints, and it prints the
same event more than once.
How could I obtain a pyglet version of the pygame code above?
Thank you.
--
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+unsubscr...@googlegroups.com
<mailto:pyglet-users+unsubscr...@googlegroups.com>.
To post to this group, send email to pyglet-users@googlegroups.com
<mailto:pyglet-users@googlegroups.com>.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
--
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+unsubscr...@googlegroups.com.
To post to this group, send email to pyglet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.