Run pyglet in headless mode

Viewed 644

I am trying to pyglet to render images and save them to .PNG files. I would like to do this without the animation window popping up. Is there any way to run pyglet in headless mode, such that the window does not pop up, but my image is still rendered and saved?

1 Answers

To run pyglet in headless mode,you should understand pyglet.options which is a dictionary including the running options of pyglet.

To set an option, just do import pyglet;pyglet.option["..."] = ...

Plese note that you must set options before importing or using any other modules of pyglet, or the options may not work.

In your question, you may need to set pyglet.options["headless"] to True to enable headless mode.

import pyglet
pyglet.options["headless"] = True
# do your work

Although it is possible to enable headless mode in pyglet,I still suggest you use other image processing module like pillow instead of pyglet

Related