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?
Asked
Active
Viewed 1,013 times
5
-
what do you try to render? Maybe you should use modules like `pillow` to render image without using GUI? I don't know if `pyglet` has function to run headless - because it was created to display GUI. On Linux you could try to use [fake screen](https://github.com/cgoldberg/xvfbwrapper) – furas Mar 09 '20 at 02:51
1 Answers
2
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

yiheng
- 51
- 6
-
For what it's worth, this didn't work for me (running on my school's Linux cluster). I don't know why. – Neil Traft Nov 06 '22 at 19:57