asteroids/venv/lib/python3.11/site-packages/pygame/docs/generated/ref/context.html

247 lines
13 KiB
HTML
Raw Normal View History

2024-10-08 15:38:46 +03:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>pygame.context &#8212; pygame v2.1.3 documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/pygame.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<link rel="shortcut icon" href="../_static/pygame.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="pygame.cursors" href="cursors.html" />
<link rel="prev" title="Named Colors" href="color_list.html" />
</head><body>
<div class="document">
<div class="header">
<div class="flex-container">
<div class="logo">
<a href="https://www.pygame.org/">
<img src="../_static/pygame_tiny.png"/>
</a>
<h5>pygame documentation</h5>
</div>
<div class="pagelinks">
<div class="top">
<a href="https://www.pygame.org/">Pygame Home</a> ||
<a href="../index.html">Help Contents</a> ||
<a href="../genindex.html">Reference Index</a>
<form action="../search.html" method="get" style="display:inline;float:right;">
<input name="q" value="" type="text">
<input value="search" type="submit">
</form>
</div>
<hr style="color:black;border-bottom:none;border-style: dotted;border-bottom-style:none;">
<p class="bottom"><b>Most useful stuff</b>:
<a href="color.html">Color</a> |
<a href="display.html">display</a> |
<a href="draw.html">draw</a> |
<a href="event.html">event</a> |
<a href="font.html">font</a> |
<a href="image.html">image</a> |
<a href="key.html">key</a> |
<a href="locals.html">locals</a> |
<a href="mixer.html">mixer</a> |
<a href="mouse.html">mouse</a> |
<a href="rect.html">Rect</a> |
<a href="surface.html">Surface</a> |
<a href="time.html">time</a> |
<a href="music.html">music</a> |
<a href="pygame.html">pygame</a>
</p>
<p class="bottom"><b>Advanced stuff</b>:
<a href="cursors.html">cursors</a> |
<a href="joystick.html">joystick</a> |
<a href="mask.html">mask</a> |
<a href="sprite.html">sprite</a> |
<a href="transform.html">transform</a> |
<a href="bufferproxy.html">BufferProxy</a> |
<a href="freetype.html">freetype</a> |
<a href="gfxdraw.html">gfxdraw</a> |
<a href="midi.html">midi</a> |
<a href="pixelarray.html">PixelArray</a> |
<a href="pixelcopy.html">pixelcopy</a> |
<a href="sndarray.html">sndarray</a> |
<a href="surfarray.html">surfarray</a> |
<a href="math.html">math</a>
</p>
<p class="bottom"><b>Other</b>:
<a href="camera.html">camera</a> |
<a href="context.html">context</a> |
<a href="sdl2_controller.html#module-pygame._sdl2.controller">controller</a> |
<a href="examples.html">examples</a> |
<a href="fastevent.html">fastevent</a> |
<a href="scrap.html">scrap</a> |
<a href="tests.html">tests</a> |
<a href="touch.html">touch</a> |
<a href="pygame.html#module-pygame.version">version</a>
</p>
</div>
</div>
</div>
<div class="documentwrapper">
<div class="body" role="main">
<section id="module-pygame.context">
<span id="pygame-context"></span><dl class="definition">
<dt class="title module sig sig-object">
<code class="docutils literal notranslate"><span class="pre">pygame.context</span></code></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">pygame module to provide additional context about the system</span></div>
</div>
<table class="toc docutils align-default">
<colgroup>
<col style="width: 40%" />
<col style="width: 1%" />
<col style="width: 59%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><div class="line"><a class="toc reference external" href="context.html#pygame.context.get_pref_path">pygame.context.get_pref_path</a></div>
</td>
<td></td>
<td>get a writeable folder for your app</td>
</tr>
<tr class="row-even"><td><div class="line"><a class="toc reference external" href="context.html#pygame.context.get_pref_locales">pygame.context.get_pref_locales</a></div>
</td>
<td></td>
<td>get preferred locales set on the system</td>
</tr>
</tbody>
</table>
<p><strong>EXPERIMENTAL!</strong> This API may change or disappear in later pygame releases.
If you use this, your code may break with the next pygame release.
This is a new module, so we are marking it experimental for now.
We probably won't have to change API, but we're keeping the possibility
open just in case something obvious comes up.</p>
<div class="versionadded">
<p><span class="versionmodified added">New in pygame 2.1.3.</span></p>
</div>
<dl class="py function definition">
<dt class="sig sig-object py title" id="pygame.context.get_pref_path">
<span class="sig-prename descclassname"><span class="pre">pygame.context.</span></span><span class="sig-name descname"><span class="pre">get_pref_path</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pygame.context.get_pref_path" title="Permalink to this definition"></a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">get a writeable folder for your app</span></div>
<div class="line"><span class="signature">get_pref_path(org, app) -&gt; path</span></div>
</div>
<p>When distributing apps, it's helpful to have a way to get a writeable path,
because it's what apps are expected to do, and because sometimes the local
space around the app isn't writeable to the app.</p>
<p>This function returns a platform specific path for your app to store
savegames, settings, and the like. This path is unique per user and
per app name.</p>
<p>It takes two strings, <code class="docutils literal notranslate"><span class="pre">org</span></code> and <code class="docutils literal notranslate"><span class="pre">app</span></code>, referring to the &quot;organization&quot;
and &quot;application name.&quot; For example, the organization could be &quot;Valve,&quot;
and the application name could be &quot;Half Life 2.&quot; It then will figure out the
preferred path, <strong>creating the folders referenced by the path if necessary</strong>,
and return a string containing the absolute path.</p>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">On</span> <span class="n">Windows</span><span class="p">,</span> <span class="n">it</span> <span class="n">would</span> <span class="n">resemble</span>
<span class="n">C</span><span class="p">:</span>\\<span class="n">Users</span>\\<span class="n">bob</span>\\<span class="n">AppData</span>\\<span class="n">Roaming</span>\\<span class="n">My</span> <span class="n">Company</span>\\<span class="n">My</span> <span class="n">Program</span> <span class="n">Name</span>\\
<span class="n">On</span> <span class="n">macOS</span><span class="p">,</span> <span class="n">it</span> <span class="n">would</span> <span class="n">resemble</span>
<span class="o">/</span><span class="n">Users</span><span class="o">/</span><span class="n">bob</span><span class="o">/</span><span class="n">Library</span><span class="o">/</span><span class="n">Application</span> <span class="n">Support</span><span class="o">/</span><span class="n">My</span> <span class="n">Program</span> <span class="n">Name</span><span class="o">/</span>
<span class="n">And</span> <span class="n">on</span> <span class="n">Linux</span> <span class="n">it</span> <span class="n">would</span> <span class="n">resemble</span>
<span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">bob</span><span class="o">/.</span><span class="n">local</span><span class="o">/</span><span class="n">share</span><span class="o">/</span><span class="n">My</span> <span class="n">Program</span> <span class="n">Name</span><span class="o">/</span>
</pre></div>
</div>
<div class="versionadded">
<p><span class="versionmodified added">New in pygame 2.1.3.</span></p>
</div>
</dd></dl>
<dl class="py function definition">
<dt class="sig sig-object py title" id="pygame.context.get_pref_locales">
<span class="sig-prename descclassname"><span class="pre">pygame.context.</span></span><span class="sig-name descname"><span class="pre">get_pref_locales</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pygame.context.get_pref_locales" title="Permalink to this definition"></a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">get preferred locales set on the system</span></div>
<div class="line"><span class="signature">get_pref_locales() -&gt; list[locale]</span></div>
</div>
<p>Returns a list of &quot;locale&quot; dicts, sorted in descending order of preference
set on the host OS (the most preferred locale is the first element). May
also be an empty list if pygame could not find this information.</p>
<p>Each &quot;locale&quot; dict contains the language code which can be accessed by the
key <code class="docutils literal notranslate"><span class="pre">&quot;language&quot;</span></code>. This language code is an ISO-639 language specifier
(such as &quot;en&quot; for English, &quot;de&quot; for German, etc).
A &quot;locale&quot; dict may also optionally contain a <code class="docutils literal notranslate"><span class="pre">&quot;country&quot;</span></code> field, whose
value is an ISO-3166 country code (such as &quot;US&quot; for the United States,
&quot;CA&quot; for Canada, etc). If this field is not set or undetermined, it is
<code class="docutils literal notranslate"><span class="pre">None</span></code>.
A &quot;locale&quot; dict which looks like <code class="docutils literal notranslate"><span class="pre">{'language':</span> <span class="pre">'en',</span> <span class="pre">'country':</span> <span class="pre">'US'}</span></code>
indicates the user prefers American English, while
<code class="docutils literal notranslate"><span class="pre">{'language':</span> <span class="pre">'en',</span> <span class="pre">'country':</span> <span class="pre">None}</span></code> indicates that the user prefers
English, generically.</p>
<p>This might be a bit of an expensive call because it has to query the OS. So
this function must not be called in a game loop, instead it's best to ask
for this once and save the results. However, this list can change when the
user changes a system preference outside of your program. pygame will send
a <code class="docutils literal notranslate"><span class="pre">LOCALECHANGED</span></code> event in this case, if possible, and you can call this
function again to get an updated copy of preferred locales.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Since the organization and app names can potentially be used as
a folder name, it is highly encouraged to avoid punctuation.
Instead stick to letters, numbers, and spaces.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The <code class="docutils literal notranslate"><span class="pre">appdirs</span></code> library has similar functionality for this use case,
but has more &quot;folder types&quot; to choose from.</p>
</div>
<div class="versionadded">
<p><span class="versionmodified added">New in pygame 2.1.3.</span></p>
</div>
</dd></dl>
</dd></dl>
</section>
<br /><br />
<hr />
<a href="https://github.com/pygame/pygame/edit/main/docs/reST/ref/context.rst" rel="nofollow">Edit on GitHub</a>
<div class="clearer"></div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="cursors.html" title="pygame.cursors"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="color_list.html" title="Named Colors"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">pygame v2.1.3 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">pygame.context</span></code></a></li>
<script type="text/javascript" src="https://www.pygame.org/comment/jquery.plugin.docscomments.js"></script>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2000-2022, pygame developers.
</div>
</body>
</html>