I'm building a real-time sound controller.
I tried to put the sound player and detector of keypress in different
threads, and used a variable as the messenger. Below is the demo code:
## detector
def wait():
while True:
win.dispatch_events()
shared.pressing = e['key'] # the got key
if shared.figure_released:
shared.pressing = None
time.sleep(0.01)
td = threading.Thread(target=wait)
td.start()
## player
while 1:
if shared.pressing=='k':
# pitch up
elif shared.pressing=='j':
# pitch down
And then I got the error:
> *RuntimeError: EventLoop.run() must be called from the same thread that
> imports pyglet.app*
Why can't pyglet get the events from another thread?
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.