Search code examples
pythonpyglet

Run pyglet.run() while still continuing with loop


I am writing a script that creates windows when given a command.

My problem is that calling pyglet.run() stops the loop.

I have tried calling pyglet.run() in a separate script so it could run simultaneously as well as trying to call it with multiprocessing.

This is the relevant code:

import pyglet
windows = []
while True:
    print('Command')
    command = input()
    if command == 'Make Window':
        windows.append(pyglet.window.Window(800, 600, 'My Window'))
        pyglet.app.run()

Solution

  • pyglet has its own loop, defined by pyglet.app.run(). Either work with pyglet default functions or call new functions in pyglet's loop