477 lines
33 KiB
HTML
477 lines
33 KiB
HTML
|
<!DOCTYPE html>
|
||
|
|
||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
|
<head>
|
||
|
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<title>Advanced GUI — Ren'Py Documentation</title>
|
||
|
<link rel="stylesheet" href="_static/renpydoc.css" type="text/css" />
|
||
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||
|
<link rel="stylesheet" type="text/css" href="_static/bootstrap-3.3.6/css/bootstrap.min.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="_static/bootstrap-3.3.6/css/bootstrap-theme.min.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="_static/bootstrap-sphinx.css" />
|
||
|
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
||
|
<script type="text/javascript" src="_static/jquery.js"></script>
|
||
|
<script type="text/javascript" src="_static/underscore.js"></script>
|
||
|
<script type="text/javascript" src="_static/doctools.js"></script>
|
||
|
<script type="text/javascript" src="_static/language_data.js"></script>
|
||
|
<script type="text/javascript" src="_static/js/jquery-1.11.0.min.js"></script>
|
||
|
<script type="text/javascript" src="_static/js/jquery-fix.js"></script>
|
||
|
<script type="text/javascript" src="_static/bootstrap-3.3.6/js/bootstrap.min.js"></script>
|
||
|
<script type="text/javascript" src="_static/bootstrap-sphinx.js"></script>
|
||
|
<link rel="index" title="Index" href="genindex.html" />
|
||
|
<link rel="search" title="Search" href="search.html" />
|
||
|
<link rel="next" title="Screens and Python" href="screen_python.html" />
|
||
|
<link rel="prev" title="Transforms and Transitions in Python" href="trans_trans_python.html" />
|
||
|
<meta charset='utf-8'>
|
||
|
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
|
||
|
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
|
||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||
|
|
||
|
</head><body>
|
||
|
|
||
|
<div id="navbar" class="navbar navbar-default navbar-fixed-top">
|
||
|
<div class="container">
|
||
|
<div class="navbar-header">
|
||
|
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
|
||
|
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
|
||
|
<span class="icon-bar"></span>
|
||
|
<span class="icon-bar"></span>
|
||
|
<span class="icon-bar"></span>
|
||
|
</button>
|
||
|
<a class="navbar-brand" href="index.html">
|
||
|
Ren'Py Documentation</a>
|
||
|
<span class="navbar-text navbar-version pull-left"><b>7.5.3</b></span>
|
||
|
</div>
|
||
|
|
||
|
<div class="collapse navbar-collapse nav-collapse">
|
||
|
<ul class="nav navbar-nav">
|
||
|
|
||
|
<li><a href="https://www.renpy.org">Home Page</a></li>
|
||
|
<li><a href="https://www.renpy.org/doc/html/">Online Documentation</a></li>
|
||
|
|
||
|
|
||
|
<li class="dropdown globaltoc-container">
|
||
|
<a role="button"
|
||
|
id="dLabelGlobalToc"
|
||
|
data-toggle="dropdown"
|
||
|
data-target="#"
|
||
|
href="index.html">Site <b class="caret"></b></a>
|
||
|
<ul class="dropdown-menu globaltoc"
|
||
|
role="menu"
|
||
|
aria-labelledby="dLabelGlobalToc"><ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">Quickstart</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="gui.html">GUI Customization Guide</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="language_basics.html">Language Basics</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="label.html">Labels & Control Flow</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="dialogue.html">Dialogue and Narration</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="displaying_images.html">Displaying Images</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="menus.html">In-Game Menus</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="python.html">Python Statements</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="conditional.html">Conditional Statements</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="audio.html">Audio</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="movie.html">Movie</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="voice.html">Voice</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="text.html">Text</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="translation.html">Translation</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="displayables.html">Displayables</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="transforms.html">Transforms</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="transitions.html">Transitions</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="atl.html">Animation and Transformation Language</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="matrixcolor.html">Matrixcolor</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="layeredimage.html">Layered Images</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="3dstage.html">3D Stage</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="live2d.html">Live2D Cubism</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="style.html">Styles</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="style_properties.html">Style Properties</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="screens.html">Screens and Screen Language</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="screen_actions.html">Screen Actions, Values, and Functions</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="screen_special.html">Special Screen Names</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="screen_optimization.html">Screen Language Optimization</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration Variables</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="preferences.html">Preference Variables</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="store_variables.html">Store Variables</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="mouse.html">Custom Mouse Cursors</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="launcher.html">Launcher</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="developer_tools.html">Developer Tools</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="director.html">Interactive Director</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="nvl_mode.html">NVL-Mode Tutorial</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="input.html">Text Input</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="side_image.html">Side Images</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="rooms.html">Image Gallery, Music Room, and Replay Actions</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="drag_drop.html">Drag and Drop</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="sprites.html">Sprites</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="keymap.html">Customizing the Keymap</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="achievement.html">Achievements</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="history.html">Dialogue History</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="multiple.html">Multiple Character Dialogue</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="splashscreen_presplash.html">Splashscreen and Presplash</a></li>
|
||
|
</ul>
|
||
|
<ul class="current">
|
||
|
<li class="toctree-l1"><a class="reference internal" href="statement_equivalents.html">Statement Equivalents</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="save_load_rollback.html">Saving, Loading, and Rollback</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="persistent.html">Persistent Data</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="trans_trans_python.html">Transforms and Transitions in Python</a></li>
|
||
|
<li class="toctree-l1 current"><a class="current reference internal" href="#">Advanced GUI</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="screen_python.html">Screens and Python</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="modes.html">Modes</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="cdd.html">Creator-Defined Displayables</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="cds.html">Creator-Defined Statements</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="custom_text_tags.html">Custom Text Tags</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="character_callbacks.html">Character Callbacks</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="file_python.html">File Access</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="color_class.html">Color Class</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="matrix.html">Matrix</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="model.html">Model-Based Rendering</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="other.html">Other Functions and Variables</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="build.html">Building Distributions</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="updater.html">Web Updater</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="android.html">Android</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="chromeos.html">Chrome OS/Chromebook</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="ios.html">iOS</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="iap.html">In-App Purchasing</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="gesture.html">Gestures</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="raspi.html">Raspberry Pi</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="security.html">Security</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="problems.html">Dealing with Problems</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="environment_variables.html">Environment Variables</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="self_voicing.html">Self-Voicing</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="editor.html">Text Editor Integration</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="skins.html">Skins</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="translating_renpy.html">Translating Ren'Py</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog (Ren'Py 7.x-)</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="changelog6.html">Changelog (Ren'Py 6.11 - 6.99)</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="incompatible.html">Incompatible Changes</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="distributor.html">Distributor Notes</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="license.html">License</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="credits.html">Credits</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="sponsors.html">Ren'Py Development Sponsors</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="thequestion.html">Script of The Question</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="thequestion_nvl.html">NVL-mode script for The Question</a></li>
|
||
|
</ul>
|
||
|
</ul>
|
||
|
</li>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
|
||
|
|
||
|
<form class="navbar-form navbar-right" action="search.html" method="get">
|
||
|
<div class="form-group">
|
||
|
<input type="text" name="q" class="form-control" placeholder="Search" />
|
||
|
</div>
|
||
|
<input type="hidden" name="check_keywords" value="yes" />
|
||
|
<input type="hidden" name="area" value="default" />
|
||
|
</form>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="container">
|
||
|
<div class="row">
|
||
|
<div class="col-md-3">
|
||
|
<div id="sidebar" class="bs-sidenav" role="complementary"><ul>
|
||
|
<li><a class="reference internal" href="#">Advanced GUI</a><ul>
|
||
|
<li><a class="reference internal" href="#python-functions">Python Functions</a><ul>
|
||
|
<li><a class="reference internal" href="#more-on-gui-rebuild">More on gui.rebuild</a></li>
|
||
|
<li><a class="reference internal" href="#the-default-statement-the-gui-namespace-and-gui-rebuild">The default statement, the gui namespace, and gui.rebuild</a></li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
<li><a class="reference internal" href="#gui-preferences">GUI Preferences</a><ul>
|
||
|
<li><a class="reference internal" href="#example">Example</a></li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="col-md-9 content">
|
||
|
|
||
|
<div class="section" id="advanced-gui">
|
||
|
<span id="gui-advanced"></span><h1>Advanced GUI<a class="headerlink" href="#advanced-gui" title="Permalink to this headline"> link</a></h1>
|
||
|
<p>This section has some odds and ends about advanced usage of the GUI.</p>
|
||
|
<div class="section" id="python-functions">
|
||
|
<h2>Python Functions<a class="headerlink" href="#python-functions" title="Permalink to this headline"> link</a></h2>
|
||
|
<p>There are some Python functions that support the GUI.</p>
|
||
|
<dl class="function">
|
||
|
<dt id="gui.button_properties">
|
||
|
<code class="descclassname">gui.</code><code class="descname">button_properties</code><span class="sig-paren">(</span><em>kind</em><span class="sig-paren">)</span><a class="headerlink" href="#gui.button_properties" title="Permalink to this definition"> link</a></dt>
|
||
|
<dd><p>Given a <cite>kind</cite> of button, returns a dictionary giving standard style
|
||
|
properties for that button. This sets:</p>
|
||
|
<dl class="docutils">
|
||
|
<dt><a class="reference internal" href="style_properties.html#style-property-background"><code class="xref std std-propref docutils literal notranslate"><span class="pre">background</span></code></a></dt>
|
||
|
<dd>As described below.</dd>
|
||
|
<dt><a class="reference internal" href="style_properties.html#style-property-padding"><code class="xref std std-propref docutils literal notranslate"><span class="pre">padding</span></code></a></dt>
|
||
|
<dd>To gui.kind_borders.padding (if it exists).</dd>
|
||
|
<dt><a class="reference internal" href="style_properties.html#style-property-xsize"><code class="xref std std-propref docutils literal notranslate"><span class="pre">xsize</span></code></a></dt>
|
||
|
<dd>To gui.kind_width (if it exists).</dd>
|
||
|
<dt><a class="reference internal" href="style_properties.html#style-property-ysize"><code class="xref std std-propref docutils literal notranslate"><span class="pre">ysize</span></code></a></dt>
|
||
|
<dd>To gui.kind_height (if it exists).</dd>
|
||
|
</dl>
|
||
|
<p>(Note that if <cite>kind</cite> is the string "nvl_button", this will look for
|
||
|
the gui.nvl_button_background variable.)</p>
|
||
|
<p>The background is a frame that takes its background picture from
|
||
|
the first existing one of:</p>
|
||
|
<ul class="simple">
|
||
|
<li>gui/button/kind_[prefix_].background.png</li>
|
||
|
<li>gui/button/[prefix_].background.png</li>
|
||
|
</ul>
|
||
|
<p>If a gui variables named gui.kind_borders exists, it's
|
||
|
used. Otherwise, <a class="reference internal" href="gui.html#var-gui.button_borders"><code class="xref std std-var docutils literal notranslate"><span class="pre">gui.button_borders</span></code></a> is used. If gui.kind_tile
|
||
|
exists, it determines if the borders are tiled, else <a class="reference internal" href="gui.html#var-gui.button_tile"><code class="xref std std-var docutils literal notranslate"><span class="pre">gui.button_tile</span></code></a>
|
||
|
controls tiling.</p>
|
||
|
<p>For what [prefix_] means, check out the <a class="reference internal" href="style_properties.html#style-prefix-search"><span class="std std-ref">style prefix search</span></a>
|
||
|
documentation.</p>
|
||
|
</dd></dl>
|
||
|
|
||
|
<dl class="function">
|
||
|
<dt id="gui.init">
|
||
|
<code class="descclassname">gui.</code><code class="descname">init</code><span class="sig-paren">(</span><em>width</em>, <em>height</em>, <em>fov=75</em><span class="sig-paren">)</span><a class="headerlink" href="#gui.init" title="Permalink to this definition"> link</a></dt>
|
||
|
<dd><p>Initializes the gui.</p>
|
||
|
<dl class="docutils">
|
||
|
<dt><cite>width</cite></dt>
|
||
|
<dd>The width of the default window.</dd>
|
||
|
<dt><cite>height</cite></dt>
|
||
|
<dd>The height of the default window.</dd>
|
||
|
<dt><cite>fov</cite></dt>
|
||
|
<dd>The field of view of the 3d stage.</dd>
|
||
|
</dl>
|
||
|
</dd></dl>
|
||
|
|
||
|
<dl class="function">
|
||
|
<dt id="gui.rebuild">
|
||
|
<code class="descclassname">gui.</code><code class="descname">rebuild</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#gui.rebuild" title="Permalink to this definition"> link</a></dt>
|
||
|
<dd><p>Rebuilds the GUI.</p>
|
||
|
<p>Note: This is a very slow function.</p>
|
||
|
</dd></dl>
|
||
|
|
||
|
<dl class="function">
|
||
|
<dt id="gui.text_properties">
|
||
|
<code class="descclassname">gui.</code><code class="descname">text_properties</code><span class="sig-paren">(</span><em>kind=None</em>, <em>accent=False</em><span class="sig-paren">)</span><a class="headerlink" href="#gui.text_properties" title="Permalink to this definition"> link</a></dt>
|
||
|
<dd><p>Given a <cite>kind</cite> of button, returns a dictionary giving standard style
|
||
|
properties for that button. This sets:</p>
|
||
|
<dl class="docutils">
|
||
|
<dt><a class="reference internal" href="style_properties.html#style-property-font"><code class="xref std std-propref docutils literal notranslate"><span class="pre">font</span></code></a></dt>
|
||
|
<dd>To gui.kind_text_font, if it exists.</dd>
|
||
|
<dt><a class="reference internal" href="style_properties.html#style-property-size"><code class="xref std std-propref docutils literal notranslate"><span class="pre">size</span></code></a></dt>
|
||
|
<dd>To gui.kind_text_size, if it exists.</dd>
|
||
|
<dt><a class="reference internal" href="style_properties.html#style-property-xalign"><code class="xref std std-propref docutils literal notranslate"><span class="pre">xalign</span></code></a></dt>
|
||
|
<dd>To gui.kind_text_xalign, if it exists.</dd>
|
||
|
<dt><a class="reference internal" href="style_properties.html#style-property-text_align"><code class="xref std std-propref docutils literal notranslate"><span class="pre">text_align</span></code></a></dt>
|
||
|
<dd>To gui.kind_text_xalign, if it exists.</dd>
|
||
|
<dt><a class="reference internal" href="style_properties.html#style-property-layout"><code class="xref std std-propref docutils literal notranslate"><span class="pre">layout</span></code></a></dt>
|
||
|
<dd>To "subtitle" if gui.kind_text_xalign is greater than zero
|
||
|
and less than one.</dd>
|
||
|
</dl>
|
||
|
<p>There are also a number of variables that set the text
|
||
|
<a class="reference internal" href="style_properties.html#style-property-color"><code class="xref std std-propref docutils literal notranslate"><span class="pre">color</span></code></a> style property:</p>
|
||
|
<dl class="docutils">
|
||
|
<dt>color</dt>
|
||
|
<dd>To gui.kind_text_color, if it exists. If the variable is not
|
||
|
set, and <cite>accent</cite> is True, sets the text color to the default
|
||
|
accent color.</dd>
|
||
|
<dt>insensitive_color</dt>
|
||
|
<dd>To gui.kind_text_insensitive_color, if it exists.</dd>
|
||
|
<dt>idle_color</dt>
|
||
|
<dd>To gui.kind_text_idle_color, if it exists.</dd>
|
||
|
<dt>hover_color</dt>
|
||
|
<dd>To gui.kind_text_hover_color, if it exists.</dd>
|
||
|
<dt>selected_color</dt>
|
||
|
<dd>To gui.kind_text_selected_color, if it exists.</dd>
|
||
|
</dl>
|
||
|
<p>All other <a class="reference internal" href="style_properties.html#text-style-properties"><span class="std std-ref">text style properties</span></a>
|
||
|
are available. When <cite>kind</cite> is not None,
|
||
|
<a class="reference internal" href="style_properties.html#position-style-properties"><span class="std std-ref">position style properties</span></a>
|
||
|
are also available. For
|
||
|
example, gui.kind_text_outlines sets the outlines style property,
|
||
|
gui.kind_text_kerning sets kerning, and so on.</p>
|
||
|
</dd></dl>
|
||
|
|
||
|
<dl class="function">
|
||
|
<dt id="gui.variant">
|
||
|
<code class="descclassname">gui.</code><code class="descname">variant</code><span class="sig-paren">(</span><em>f</em>, <em>variant=None</em><span class="sig-paren">)</span><a class="headerlink" href="#gui.variant" title="Permalink to this definition"> link</a></dt>
|
||
|
<dd><p>A decorator that causes a function to be called when the gui is first
|
||
|
initialized, and again each time the gui is rebuilt. This is intended
|
||
|
to be used as a function decorator, of the form:</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="nd">@gui</span><span class="o">.</span><span class="na">variant</span>
|
||
|
<span class="k">def</span> <span class="nf">small</span><span class="p">():</span>
|
||
|
<span class="n">gui</span><span class="o">.</span><span class="na">text_size</span> <span class="o">=</span> <span class="mi">30</span>
|
||
|
<span class="c1"># ...</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<p>It can also be called with <cite>f</cite> (a function) and <cite>variant</cite> (a string),
|
||
|
giving the variant name.</p>
|
||
|
</dd></dl>
|
||
|
|
||
|
<div class="section" id="more-on-gui-rebuild">
|
||
|
<h3>More on gui.rebuild<a class="headerlink" href="#more-on-gui-rebuild" title="Permalink to this headline"> link</a></h3>
|
||
|
<p>The gui.rebuild function is a rather slow function that updates the GUI
|
||
|
to reflect the current state of Ren'Py. What it does is:</p>
|
||
|
<ul class="simple">
|
||
|
<li>Re-runs all of the <code class="docutils literal notranslate"><span class="pre">define</span></code> statements that define variables in the gui
|
||
|
namespace.</li>
|
||
|
<li>Re-runs all of the <code class="docutils literal notranslate"><span class="pre">translate</span> <span class="pre">python</span></code> blocks for the current language.</li>
|
||
|
<li>Re-runs all of the <code class="docutils literal notranslate"><span class="pre">style</span></code> statements.</li>
|
||
|
<li>Rebuilds all of the styles in the system.</li>
|
||
|
</ul>
|
||
|
<p>Note that <code class="docutils literal notranslate"><span class="pre">init</span> <span class="pre">python</span></code> blocks are not re-run on <code class="docutils literal notranslate"><span class="pre">gui.rebuild</span></code>. In this way,</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">define</span> <span class="n">gui</span><span class="o">.</span><span class="na">text_size</span> <span class="o">=</span> <span class="n">persistent</span><span class="o">.</span><span class="na">text_size</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<p>and:</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">init</span> <span class="k">python</span><span class="p">:</span>
|
||
|
<span class="n">gui</span><span class="o">.</span><span class="na">text_size</span> <span class="o">=</span> <span class="n">persistent</span><span class="o">.</span><span class="na">text_size</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<p>are different.</p>
|
||
|
</div>
|
||
|
<div class="section" id="the-default-statement-the-gui-namespace-and-gui-rebuild">
|
||
|
<h3>The default statement, the gui namespace, and gui.rebuild<a class="headerlink" href="#the-default-statement-the-gui-namespace-and-gui-rebuild" title="Permalink to this headline"> link</a></h3>
|
||
|
<p>The <code class="docutils literal notranslate"><span class="pre">default</span></code> statement has changed semantics when applied to the <code class="docutils literal notranslate"><span class="pre">gui</span></code>
|
||
|
namespace. When applied to a variable in the <code class="docutils literal notranslate"><span class="pre">gui</span></code> namespace, the
|
||
|
default statement runs interleaved with the define statement, and
|
||
|
the default statements are not re-run when <a class="reference internal" href="#gui.rebuild" title="gui.rebuild"><code class="xref py py-func docutils literal notranslate"><span class="pre">gui.rebuild()</span></code></a> is called.</p>
|
||
|
<p>What this means is that if we have:</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">default</span> <span class="n">gui</span><span class="o">.</span><span class="n">accent_color</span> <span class="o">=</span> <span class="s2">"#c04040"</span>
|
||
|
<span class="k">define</span> <span class="n">gui</span><span class="o">.</span><span class="na">hover_color</span> <span class="o">=</span> <span class="n">gui</span><span class="o">.</span><span class="n">accent_color</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<p>The first time the game is run, the accent color will be set, and then
|
||
|
the hover color will be set to the accent color. (Both are then used to
|
||
|
set various style colors.)</p>
|
||
|
<p>However, if as part of the game script, we have:</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">$</span> <span class="n">gui</span><span class="o">.</span><span class="n">accent_color</span> <span class="o">=</span> <span class="s2">"#4040c0"</span>
|
||
|
<span class="k">$</span> <span class="n">gui</span><span class="o">.</span><span class="n">rebuild</span><span class="p">()</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<p>Ren'Py will only re-run the define, so it will set the hover color to
|
||
|
the accent color, and then update the styles. This makes it possible
|
||
|
to have parts of the GUI that change as the game progresses.</p>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="section" id="gui-preferences">
|
||
|
<span id="id1"></span><h2>GUI Preferences<a class="headerlink" href="#gui-preferences" title="Permalink to this headline"> link</a></h2>
|
||
|
<p>Ren'Py also supports a GUI preference system, consisting of a single function
|
||
|
and a pair of actions.</p>
|
||
|
<dl class="function">
|
||
|
<dt id="gui.SetPreference">
|
||
|
<code class="descclassname">gui.</code><code class="descname">SetPreference</code><span class="sig-paren">(</span><em>name</em>, <em>value</em>, <em>rebuild=True</em><span class="sig-paren">)</span><a class="headerlink" href="#gui.SetPreference" title="Permalink to this definition"> link</a></dt>
|
||
|
<dd><p>This Action sets the gui preference with <cite>name</cite> to <cite>value</cite>.</p>
|
||
|
<dl class="docutils">
|
||
|
<dt><cite>rebuild</cite></dt>
|
||
|
<dd>If true, the default, <a class="reference internal" href="#gui.rebuild" title="gui.rebuild"><code class="xref py py-func docutils literal notranslate"><span class="pre">gui.rebuild()</span></code></a> is called to make
|
||
|
the changes take effect. This should generally be true, except
|
||
|
in the case of multiple gui.SetPreference actions, in which case
|
||
|
it should be False in all but the last one.</dd>
|
||
|
</dl>
|
||
|
<p>This is a very slow action, and probably not suitable for use
|
||
|
when a button is hovered.</p>
|
||
|
</dd></dl>
|
||
|
|
||
|
<dl class="function">
|
||
|
<dt id="gui.TogglePreference">
|
||
|
<code class="descclassname">gui.</code><code class="descname">TogglePreference</code><span class="sig-paren">(</span><em>name</em>, <em>a</em>, <em>b</em>, <em>rebuild=True</em><span class="sig-paren">)</span><a class="headerlink" href="#gui.TogglePreference" title="Permalink to this definition"> link</a></dt>
|
||
|
<dd><p>This Action toggles the gui preference with <cite>name</cite> between
|
||
|
value <cite>a</cite> and value <cite>b</cite>. It is selected if the value is equal
|
||
|
to <cite>a</cite>.</p>
|
||
|
<dl class="docutils">
|
||
|
<dt><cite>rebuild</cite></dt>
|
||
|
<dd>If true, the default, <a class="reference internal" href="#gui.rebuild" title="gui.rebuild"><code class="xref py py-func docutils literal notranslate"><span class="pre">gui.rebuild()</span></code></a> is called to make
|
||
|
the changes take effect. This should generally be true, except
|
||
|
in the case of multiple gui.SetPreference actions, in which case
|
||
|
it should be False in all but the last one.</dd>
|
||
|
</dl>
|
||
|
<p>This is a very slow action, and probably not suitable for use
|
||
|
when a button is hovered.</p>
|
||
|
</dd></dl>
|
||
|
|
||
|
<dl class="function">
|
||
|
<dt id="gui.preference">
|
||
|
<code class="descclassname">gui.</code><code class="descname">preference</code><span class="sig-paren">(</span><em>name</em>, <em>default=...</em><span class="sig-paren">)</span><a class="headerlink" href="#gui.preference" title="Permalink to this definition"> link</a></dt>
|
||
|
<dd><p>This function returns the value of the gui preference with
|
||
|
<cite>name</cite>.</p>
|
||
|
<dl class="docutils">
|
||
|
<dt><cite>default</cite></dt>
|
||
|
<dd>If given, this value becomes the default value of the gui
|
||
|
preference. The default value must be given the first time
|
||
|
the preference is used.</dd>
|
||
|
</dl>
|
||
|
</dd></dl>
|
||
|
|
||
|
<div class="section" id="example">
|
||
|
<h3>Example<a class="headerlink" href="#example" title="Permalink to this headline"> link</a></h3>
|
||
|
<p>The GUI preference system is used by calling <a class="reference internal" href="#gui.preference" title="gui.preference"><code class="xref py py-func docutils literal notranslate"><span class="pre">gui.preference()</span></code></a> when defining
|
||
|
variables, with the name of the preference and the default value.
|
||
|
For example, one can use GUI preferences to define the text font and
|
||
|
size.</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">define</span> <span class="n">gui</span><span class="o">.</span><span class="na">text_font</span> <span class="o">=</span> <span class="n">gui</span><span class="o">.</span><span class="n">preference</span><span class="p">(</span><span class="s2">"font"</span><span class="p">,</span> <span class="s2">"DejaVuSans.ttf"</span><span class="p">)</span>
|
||
|
<span class="k">define</span> <span class="n">gui</span><span class="o">.</span><span class="na">text_size</span> <span class="o">=</span> <span class="n">gui</span><span class="o">.</span><span class="n">preference</span><span class="p">(</span><span class="s2">"size"</span><span class="p">,</span> <span class="mi">22</span><span class="p">)</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<p>It's then possible to use the <a class="reference internal" href="#gui.SetPreference" title="gui.SetPreference"><code class="xref py py-class docutils literal notranslate"><span class="pre">gui.SetPreference</span></code></a> and <a class="reference internal" href="#gui.TogglePreference" title="gui.TogglePreference"><code class="xref py py-class docutils literal notranslate"><span class="pre">gui.TogglePreference</span></code></a>
|
||
|
actions to add change the values of the preferences. Here's some examples
|
||
|
that can be added to the preferences screen.</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">vbox</span><span class="p">:</span>
|
||
|
<span class="na">style_prefix</span> <span class="s2">"check"</span>
|
||
|
<span class="k">label</span> <span class="n">_</span><span class="p">(</span><span class="s2">"Options"</span><span class="p">)</span>
|
||
|
<span class="k">textbutton</span> <span class="n">_</span><span class="p">(</span><span class="s2">"OpenDyslexic"</span><span class="p">)</span> <span class="na">action</span> <span class="n">gui</span><span class="o">.</span><span class="n">TogglePreference</span><span class="p">(</span><span class="s2">"font"</span><span class="p">,</span> <span class="s2">"OpenDyslexic-Regular.otf"</span><span class="p">,</span> <span class="s2">"DejaVuSans.ttf"</span><span class="p">)</span>
|
||
|
|
||
|
<span class="k">vbox</span><span class="p">:</span>
|
||
|
<span class="na">style_prefix</span> <span class="s2">"radio"</span>
|
||
|
<span class="k">label</span> <span class="n">_</span><span class="p">(</span><span class="s2">"Text Size"</span><span class="p">)</span>
|
||
|
<span class="k">textbutton</span> <span class="n">_</span><span class="p">(</span><span class="s2">"Small"</span><span class="p">)</span> <span class="na">action</span> <span class="n">gui</span><span class="o">.</span><span class="n">SetPreference</span><span class="p">(</span><span class="s2">"size"</span><span class="p">,</span> <span class="mi">20</span><span class="p">)</span>
|
||
|
<span class="k">textbutton</span> <span class="n">_</span><span class="p">(</span><span class="s2">"Medium"</span><span class="p">)</span> <span class="na">action</span> <span class="n">gui</span><span class="o">.</span><span class="n">SetPreference</span><span class="p">(</span><span class="s2">"size"</span><span class="p">,</span> <span class="mi">22</span><span class="p">)</span>
|
||
|
<span class="k">textbutton</span> <span class="n">_</span><span class="p">(</span><span class="s2">"Big"</span><span class="p">)</span> <span class="na">action</span> <span class="n">gui</span><span class="o">.</span><span class="n">SetPreference</span><span class="p">(</span><span class="s2">"size"</span><span class="p">,</span> <span class="mi">24</span><span class="p">)</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
<footer class="footer">
|
||
|
<div class="container">
|
||
|
<p class="pull-right">
|
||
|
<a href="#">Back to top</a>
|
||
|
|
||
|
</p>
|
||
|
<p>
|
||
|
© Copyright 2012-2022, Tom Rothamel.<br/>
|
||
|
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.6.<br/>
|
||
|
</p>
|
||
|
</div>
|
||
|
</footer>
|
||
|
</body>
|
||
|
</html>
|