Debian Codegraph @

doc/programming_guide/options.rst

raw
1 Runtime Options
2 ===============
3
4 Pyglet offers a way to change runtime behavior through options. These options provide ways to modify specific modules, behavior for specific operating systems, or adding more debugging information. Options can be specified as a key, or as an attribute with the ``pyglet.options`` dataclass instance.
5
6 To change an option from its default, you must import ``pyglet`` before any sub-packages.
7
8 For example::
9
10 import pyglet
11 pyglet.options['debug_gl'] = False
12 pyglet.options.debug_media = True
13
14 The default options can be overridden from the OS environment as well. The
15 corresponding environment variable for each option key is prefaced by
16 ``PYGLET_``. For example, in Bash you can set the ``debug_gl`` option with::
17
18 PYGLET_DEBUG_GL=True; export PYGLET_DEBUG_GL
19
20 For options requiring a tuple of values, separate each value with a comma.
21
22 .. autoclass:: pyglet.Options
23 :members:
24 :exclude-members: __init__, __new__
25
26 .. autodata:: pyglet.options
27
28 .. _guide_environment-settings:
29
30 Environment settings
31 --------------------
32
33 The default :py:class:`pyglet.Options` instance (:py:attr:`pyglet.options`)
34 can read default values from the operating system's environment variable. The
35 following table shows which environment variable is used for each option:
36
37 .. list-table::
38 :header-rows: 1
39
40 * - Environment variable
41 - :py:attr:`pyglet.options` key
42 - Type
43 - Default value
44 * - ``PYGLET_AUDIO``
45 - ``audio``
46 - List of strings
47 - ``directsound,openal,alsa,silent``
48 * - ``PYGLET_DEBUG_GL``
49 - ``debug_gl``
50 - Boolean
51 - ``1`` [#debug_gl]_
52
53 .. [#debug_gl] Defaults to ``1`` unless Python is run with ``-O`` or from a
54 frozen executable.