1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554
|
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Screens and Python — Ren'Py Documentation</title>
<link rel="stylesheet" href="_static/screen.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="_static/renpydoc.css" type="text/css" media="print" />
<!--[if lt IE 8]>
<link rel="stylesheet" href="_static/renpydoc.css" type="text/css" media="screen, projection"/>
<![endif]-->
<link rel="stylesheet" href="_static/renpydoc.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '6.18.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</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>
<link rel="top" title="Ren'Py Documentation" href="index.html" />
<link rel="next" title="Modes" href="modes.html" />
<link rel="prev" title="Transforms and Transitions in Python" href="trans_trans_python.html" />
</head>
<body>
<div class="related">
<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="modes.html" title="Modes"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="trans_trans_python.html" title="Transforms and Transitions in Python"
accesskey="P">previous</a> |</li>
<li> <img src="_static/logo.png" width=19 height=21 align=center>
<li> <a href="http://www.renpy.org/">Ren'Py Home</a> |
<li><a href="index.html">Ren'Py Documentation</a></li>
</ul>
</div>
<div class="container">
<div class="span4">
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Screens and Python</a><ul>
<li><a class="reference internal" href="#screen-functions">Screen Functions</a></li>
<li><a class="reference internal" href="#ui-functions">UI Functions</a></li>
<li><a class="reference internal" href="#actions">Actions</a></li>
<li><a class="reference internal" href="#barvalues">BarValues</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="trans_trans_python.html"
title="previous chapter">Transforms and Transitions in Python</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="modes.html"
title="next chapter">Modes</a></p>
<h4>Search</h4>
<div id="cse-search-form" style="width: 100%;"></div>
<div class="copydata">
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
<br>
</div>
</div>
</div>
</div>
<div class="document span20 last">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="screens-and-python">
<h1>Screens and Python<a class="headerlink" href="#screens-and-python" title="Permalink to this headline">¶</a></h1>
<p>Ren'Py supports defining screens in Python, as well as in the Ren'Py
screen language. A Python screen is created by supplying a screen
function to the <a class="reference internal" href="#renpy.define_screen" title="renpy.define_screen"><tt class="xref py py-func docutils literal"><span class="pre">renpy.define_screen()</span></tt></a> function. It can then
be used like it was any other screen.</p>
<p>The screen function should have parameters corresponding to the scope
variables it expects, and it should ignore extra keyword
arguments. (That is, it should have <cite>**kwargs</cite> at the end of its
parameter list.) It is then expected to call the UI functions to add
displayables to the screen.The screen function is called whenever an
interaction starts or restarts.</p>
<p>To ensure that this restarting is seamless to the user (and
not causing things to reset), it's important that every call to a UI
function supply the <cite>id</cite> argument. As a screen is re-created, Ren'Py
will update each displayable with the contents of the old displayable
with the same id. Ids are generated automatically by the screen
language, but when doing things by hand, they must be manually
specified.</p>
<p>Here's an example python screen:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">init</span> <span class="k">python</span><span class="p">:</span>
<span class="k">def</span> <span class="nf">say_screen</span><span class="p">(</span><span class="n">who</span><span class="p">,</span> <span class="n">what</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="n">ui</span><span class="o">.</span><span class="k">window</span><span class="p">(</span><span class="na">id</span><span class="o">=</span><span class="s">"window"</span><span class="p">)</span>
<span class="n">ui</span><span class="o">.</span><span class="k">vbox</span><span class="p">(</span><span class="na">id</span><span class="o">=</span><span class="s">"say_vbox"</span><span class="p">)</span>
<span class="n">ui</span><span class="o">.</span><span class="k">text</span><span class="p">(</span><span class="n">who</span><span class="p">,</span> <span class="na">id</span><span class="o">=</span><span class="s">"who"</span><span class="p">)</span>
<span class="n">ui</span><span class="o">.</span><span class="k">text</span><span class="p">(</span><span class="n">what</span><span class="p">,</span> <span class="na">id</span><span class="o">=</span><span class="s">"what"</span><span class="p">)</span>
<span class="n">ui</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="n">renpy</span><span class="o">.</span><span class="n">define_screen</span><span class="p">(</span><span class="s">"say"</span><span class="p">,</span> <span class="n">say_screen</span><span class="p">)</span>
</pre></div>
</div>
<div class="section" id="screen-functions">
<h2>Screen Functions<a class="headerlink" href="#screen-functions" title="Permalink to this headline">¶</a></h2>
<p>The following functions support the definition, display, and hiding of
screens.</p>
<dl class="function">
<dt id="renpy.call_screen">
<tt class="descclassname">renpy.</tt><tt class="descname">call_screen</tt><big>(</big><em>_screen_name</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#renpy.call_screen" title="Permalink to this definition">¶</a></dt>
<dd><p>The programmatic equivalent of the show screen statement.</p>
<p>This shows <cite>_screen_name</cite> as a screen, then causes an interaction
to occur. The screen is hidden at the end of the interaction, and
the result of the interaction is returned.</p>
<p>Keyword arguments not beginning with _ are passed to the scope of
the screen.</p>
<p>If the keyword argument <cite>_with_none</cite> is false, "with None" is not
run at the end of end of the interaction.</p>
</dd></dl>
<dl class="function">
<dt id="renpy.define_screen">
<tt class="descclassname">renpy.</tt><tt class="descname">define_screen</tt><big>(</big><em>name</em>, <em>function</em>, <em>modal="False"</em>, <em>zorder="0"</em>, <em>tag=None</em>, <em>variant=None</em><big>)</big><a class="headerlink" href="#renpy.define_screen" title="Permalink to this definition">¶</a></dt>
<dd><p>Defines a screen with <cite>name</cite>, which should be a string.</p>
<dl class="docutils">
<dt><cite>function</cite></dt>
<dd><p class="first">The function that is called to display the screen. The
function is called with the screen scope as keyword
arguments. It should ignore additional keyword arguments.</p>
<p class="last">The function should call the ui functions to add things to the
screen.</p>
</dd>
<dt><cite>modal</cite></dt>
<dd>A string that, when evaluated, determines of the created
screen should be modal. A modal screen prevents screens
underneath it from receiving input events.</dd>
<dt><cite>zorder</cite></dt>
<dd>A string that, when evaluated, should be an integer. The integer
controls the order in which screens are displayed. A screen
with a greater zorder number is displayed above screens with a
lesser zorder number.</dd>
<dt><cite>tag</cite></dt>
<dd>The tag associated with this screen. When the screen is shown,
it replaces any other screen with the same tag. The tag
defaults to the name of the screen.</dd>
<dt><cite>predict</cite></dt>
<dd>If true, this screen can be loaded for image prediction. If false,
it can't. Defaults to true.</dd>
<dt><cite>variant</cite></dt>
<dd>String. Gives the variant of the screen to use.</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="renpy.get_screen">
<tt class="descclassname">renpy.</tt><tt class="descname">get_screen</tt><big>(</big><em>name</em>, <em>layer='screens'</em><big>)</big><a class="headerlink" href="#renpy.get_screen" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the ScreenDisplayable with the given <cite>tag</cite>, on
<cite>layer</cite>. If no displayable with the tag is not found, it is
interpreted as screen name. If it's still not found, None is returned.</p>
</dd></dl>
<dl class="function">
<dt id="renpy.get_widget">
<tt class="descclassname">renpy.</tt><tt class="descname">get_widget</tt><big>(</big><em>screen</em>, <em>id</em>, <em>layer='screens'</em><big>)</big><a class="headerlink" href="#renpy.get_widget" title="Permalink to this definition">¶</a></dt>
<dd><p>From the <cite>screen</cite> on <cite>layer</cite>, returns the widget with
<cite>id</cite>. Returns None if the screen doesn't exist, or there is no
widget with that id on the screen.</p>
</dd></dl>
<dl class="function">
<dt id="renpy.hide_screen">
<tt class="descclassname">renpy.</tt><tt class="descname">hide_screen</tt><big>(</big><em>tag</em>, <em>layer='screens'</em><big>)</big><a class="headerlink" href="#renpy.hide_screen" title="Permalink to this definition">¶</a></dt>
<dd><p>The programmatic equivalent of the hide screen statement.</p>
<p>Hides the screen with <cite>tag</cite> on <cite>layer</cite>.</p>
</dd></dl>
<dl class="function">
<dt id="renpy.show_screen">
<tt class="descclassname">renpy.</tt><tt class="descname">show_screen</tt><big>(</big><em>_screen_name</em>, <em>*_args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#renpy.show_screen" title="Permalink to this definition">¶</a></dt>
<dd><p>The programmatic equivalent of the show screen statement.</p>
<p>Shows the named screen. This takes the following keyword arguments:</p>
<dl class="docutils">
<dt><cite>_screen_name</cite></dt>
<dd>The name of the screen to show.</dd>
<dt><cite>_layer</cite></dt>
<dd>The layer to show the screen on.</dd>
<dt><cite>_tag</cite></dt>
<dd>The tag to show the screen with. If not specified, defaults to
the tag associated with the screen. It that's not specified,
defaults to the name of the screen.,</dd>
<dt><cite>_widget_properties</cite></dt>
<dd>A map from the id of a widget to a property name -> property
value map. When a widget with that id is shown by the screen,
the specified properties are added to it.</dd>
<dt><cite>_transient</cite></dt>
<dd>If true, the screen will be automatically hidden at the end of
the current interaction.</dd>
</dl>
<p>Keyword arguments not beginning with underscore (_) are used to
initialize the screen's scope.</p>
</dd></dl>
<dl class="function">
<dt id="renpy.variant">
<tt class="descclassname">renpy.</tt><tt class="descname">variant</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#renpy.variant" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns true if a <cite>name</cite> is a screen variant that can be chosen
by Ren'Py. See <a class="reference internal" href="screens.html#screen-variants"><em>Screen Variants</em></a> for more details. This function
can be used as the condition in a python if statement to set up the
appropriate styles for the selected screen variant.</p>
<p><cite>name</cite> can also be a list of variants, in which case this function
returns True if any of the variants is selected.</p>
</dd></dl>
</div>
<div class="section" id="ui-functions">
<h2>UI Functions<a class="headerlink" href="#ui-functions" title="Permalink to this headline">¶</a></h2>
<p>The UI functions are python equivalents of the screen language
statements. For each screen language statement, there is a ui function
with the same name. For example, ui.text corresponds to the text
statement, and ui.add corresponds to the add statement.</p>
<p>There is a simple mapping between screen language parameters and
arguments and python arguments. Screen language parameters
become positional arguments, while properties become keyword
arguments. For example, the screen language statement:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">text</span> <span class="s">"Hello, World"</span> <span class="na">size</span> <span class="mi">40</span> <span class="na">xalign</span> <span class="mf">0.5</span>
</pre></div>
</div>
<p>becomes:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="n">ui</span><span class="o">.</span><span class="k">text</span><span class="p">(</span><span class="s">"Hello, World"</span><span class="p">,</span> <span class="na">size</span><span class="o">=</span><span class="mi">40</span><span class="p">,</span> <span class="na">xalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
</pre></div>
</div>
<p>(It really should have an <cite>id</cite> parameter added.)</p>
<p>There are three groups of UI functions, corresponding to the number
of children they take.</p>
<p>The following UI functions do not take any children.</p>
<ul class="simple">
<li>ui.add</li>
<li>ui.bar</li>
<li>ui.imagebutton</li>
<li>ui.input</li>
<li>ui.key</li>
<li>ui.label</li>
<li>ui.null</li>
<li>ui.text</li>
<li>ui.textbutton</li>
<li>ui.timer</li>
<li>ui.vbar</li>
<li>ui.hotspot</li>
<li>ui.hotbar</li>
<li>ui.spritemanager</li>
</ul>
<p>The following UI functions take a single child. They must be given
that child - use ui.null() if the child is missing.</p>
<ul class="simple">
<li>ui.button</li>
<li>ui.frame</li>
<li>ui.transform</li>
<li>ui.window</li>
<li>ui.drag</li>
</ul>
<p>The following UI functions take multiple children. They continue
taking children until <a class="reference internal" href="#ui.close" title="ui.close"><tt class="xref py py-func docutils literal"><span class="pre">ui.close()</span></tt></a> is called.</p>
<ul class="simple">
<li>ui.fixed</li>
<li>ui.grid</li>
<li>ui.hbox</li>
<li>ui.side</li>
<li>ui.vbox</li>
<li>ui.imagemap</li>
<li>ui.draggroup</li>
</ul>
<p>There are a few UI functions that do not correspond to screen language
statments, as they correspond to concepts that are not present in the
screen language.</p>
<dl class="function">
<dt id="ui.adjustment">
<tt class="descclassname">ui.</tt><tt class="descname">adjustment</tt><big>(</big><em>range=1</em>, <em>value=0</em>, <em>step=None</em>, <em>page=0</em>, <em>changed=None</em>, <em>adjustable=None</em>, <em>ranged=None</em><big>)</big><a class="headerlink" href="#ui.adjustment" title="Permalink to this definition">¶</a></dt>
<dd><p>Adjustment objects represent a value that can be adjusted by a bar
or viewport. They contain information about the value, the range
of the value, and how to adjust the value in small steps and large
pages.</p>
<p>The following parameters correspond to fields or properties on
the adjustment object:</p>
<dl class="docutils">
<dt><cite>range</cite></dt>
<dd>The range of the adjustment, a number.</dd>
<dt><cite>value</cite></dt>
<dd>The value of the adjustment, a number.</dd>
<dt><cite>step</cite></dt>
<dd><p class="first">The step size of the adjustment, a number. If None, then
defaults to 1/10th of a page, if set. Otherwise, defaults
to the 1/20th of the range.</p>
<p class="last">This is used when scrolling a viewport with the mouse wheel.</p>
</dd>
<dt><cite>page</cite></dt>
<dd><p class="first">The page size of the adjustment. If None, this is set
automatically by a viewport. If never set, defaults to 1/10th
of the range.</p>
<p class="last">It's can be used when clicking on a scrollbar.</p>
</dd>
</dl>
<p>The following parameters control the behavior of the adjustment.</p>
<dl class="docutils">
<dt><cite>adjustable</cite></dt>
<dd><p class="first">If True, this adjustment can be changed by a bar. If False,
it can't.</p>
<p class="last">It defaults to being adjustable if a <cite>changed</cite> function
is given or if the adjustment is associated with a viewport,
and not adjustable otherwise.</p>
</dd>
<dt><cite>changed</cite></dt>
<dd>This function is called with the new value when the value of
the adjustment changes.</dd>
<dt><cite>ranged</cite></dt>
<dd>This function is called with the adjustment object when
the range of the adjustment is set by a viewport.</dd>
</dl>
<dl class="method">
<dt id="change">
<tt class="descname">change</tt><big>(</big><em>value</em><big>)</big><a class="headerlink" href="#change" title="Permalink to this definition">¶</a></dt>
<dd><p>Changes the value of the adjustment to <cite>value</cite>, updating
any bars and viewports that use the adjustment.</p>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="ui.at">
<tt class="descclassname">ui.</tt><tt class="descname">at</tt><big>(</big><em>transform</em><big>)</big><a class="headerlink" href="#ui.at" title="Permalink to this definition">¶</a></dt>
<dd><p>Specifieds a transform that is applied to the next displayable to
be created. This is largely obsolete, as all UI functions now take
an <cite>at</cite> argument.</p>
</dd></dl>
<dl class="function">
<dt id="ui.close">
<tt class="descclassname">ui.</tt><tt class="descname">close</tt><big>(</big><big>)</big><a class="headerlink" href="#ui.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Closes a displayable created with by a UI function. When a
displayable is closed, we add new displayables to its parent,
or to the layer if no displayable is open.</p>
</dd></dl>
<dl class="function">
<dt id="ui.detached">
<tt class="descclassname">ui.</tt><tt class="descname">detached</tt><big>(</big><big>)</big><a class="headerlink" href="#ui.detached" title="Permalink to this definition">¶</a></dt>
<dd><p>Do not add the next displayable to any later or container. Use this if
you want to assign the result of a ui function to a variable.</p>
</dd></dl>
<dl class="function">
<dt id="ui.layer">
<tt class="descclassname">ui.</tt><tt class="descname">layer</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#ui.layer" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds displayables to the layer named <cite>name</cite>. The later must be
closed with <a class="reference internal" href="#ui.close" title="ui.close"><tt class="xref py py-func docutils literal"><span class="pre">ui.close()</span></tt></a>.</p>
</dd></dl>
</div>
<div class="section" id="actions">
<h2>Actions<a class="headerlink" href="#actions" title="Permalink to this headline">¶</a></h2>
<p>Many of the displayables created in the screen language take actions
as arguments. An action is one of three things:</p>
<ul class="simple">
<li>A callable python object (like a function or bound method) that
takes no arguments.</li>
<li>An object of a class that inherits from the Action class.</li>
<li>A list of other Actions.</li>
</ul>
<p>The advantage to inheriting from the Action class is that it allows
you to override the methods that determine when a button should be
sensitive, and when it is selected.</p>
<dl class="class">
<dt id="Action">
<em class="property">class </em><tt class="descname">Action</tt><a class="headerlink" href="#Action" title="Permalink to this definition">¶</a></dt>
<dd><p>To define a new action, inherit from this class. Override the
methods in this class to change the behavior of the action.</p>
<dl class="method">
<dt id="Action.__call__">
<tt class="descname">__call__</tt><big>(</big><em>self</em><big>)</big><a class="headerlink" href="#Action.__call__" title="Permalink to this definition">¶</a></dt>
<dd><p>This is the method that is called when the action is
activated. In many cases, returning a non-None value from the
action will cause the current interaction to end.</p>
<p>This method must be overriden, as the default method will
raise NotImplemented (and hence cause Ren'Py to report an
error).</p>
</dd></dl>
<dl class="method">
<dt id="Action.get_sensitive">
<tt class="descname">get_sensitive</tt><big>(</big><em>self</em><big>)</big><a class="headerlink" href="#Action.get_sensitive" title="Permalink to this definition">¶</a></dt>
<dd><p>This is called to determine if the button with this action
should be sensitive. It should return true if the button is
sensitive.</p>
<p>Note that __call__ can be called, even if this returns False.</p>
<p>The default implementation returns True.</p>
</dd></dl>
<dl class="method">
<dt id="Action.get_selected">
<tt class="descname">get_selected</tt><big>(</big><em>self</em><big>)</big><a class="headerlink" href="#Action.get_selected" title="Permalink to this definition">¶</a></dt>
<dd><p>This should return true if the button should be rendered as a
selected button, and false otherwise.</p>
<p>The default implemention returns False.</p>
</dd></dl>
<dl class="method">
<dt id="Action.periodic">
<tt class="descname">periodic</tt><big>(</big><em>self</em>, <em>st</em><big>)</big><a class="headerlink" href="#Action.periodic" title="Permalink to this definition">¶</a></dt>
<dd><p>This method is called once at the start of each interaction,
and then is called periodically thereafter. If it returns a
number, it will be called before that many seconds elapse, but
it might be called sooner.</p>
<p>The main use of this is to call
<a class="reference internal" href="other.html#renpy.restart_interaction" title="renpy.restart_interaction"><tt class="xref py py-func docutils literal"><span class="pre">renpy.restart_interaction()</span></tt></a> if the value of
get_selected or get_sensitive should change.</p>
<p>It takes one argument:</p>
<dl class="docutils">
<dt><cite>st</cite></dt>
<dd>The number of seconds since the screen or displayable this
action is associated with was first shown.</dd>
</dl>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">unhovered(self):</tt></dt>
<dd><p>When the action is used as the <cite>hovered</cite> parameter to a button (or
similar object), this method is called when the object loses focus.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="barvalues">
<h2>BarValues<a class="headerlink" href="#barvalues" title="Permalink to this headline">¶</a></h2>
<p>When creating a bar, vbar, or hotbar, a BarValue object can be supplied as
the <cite>value</cite> argument. Methods on the BarValue object are called to get
the adjustment and styles.</p>
<dl class="class">
<dt id="BarValue">
<em class="property">class </em><tt class="descname">BarValue</tt><a class="headerlink" href="#BarValue" title="Permalink to this definition">¶</a></dt>
<dd><p>To define a new BarValue, inherit from this class and override
some of the methods.</p>
<dl class="method">
<dt id="BarValue.get_adjustment">
<tt class="descname">get_adjustment</tt><big>(</big><em>self</em><big>)</big><a class="headerlink" href="#BarValue.get_adjustment" title="Permalink to this definition">¶</a></dt>
<dd><p>This method is called to get an adjustment object for the
bar. It should create the adjustment with
<a class="reference internal" href="#ui.adjustment" title="ui.adjustment"><tt class="xref py py-func docutils literal"><span class="pre">ui.adjustment()</span></tt></a>, and then return the object created this
way.</p>
<p>This method must be overriden, as the default method will
raise NotImplemented (and hence cause Ren'Py to report an
error).</p>
</dd></dl>
<dl class="method">
<dt id="BarValue.get_style">
<tt class="descname">get_style</tt><big>(</big><em>self</em><big>)</big><a class="headerlink" href="#BarValue.get_style" title="Permalink to this definition">¶</a></dt>
<dd><p>This is used to determine the style of bars that use this
value. It should return a tuple of two style names or style
objects. The first is used for a bar, and the
second for vbar.</p>
<p>This defaults to ("bar", "vbar").</p>
</dd></dl>
<dl class="method">
<dt id="BarValue.replaces">
<tt class="descname">replaces</tt><big>(</big><em>self</em>, <em>other</em><big>)</big><a class="headerlink" href="#BarValue.replaces" title="Permalink to this definition">¶</a></dt>
<dd><p>This is called when a BarValue replaces another BarValue, such
as when a screen is updated. It can be used to update this
BarValue from the other. It is called before get_adjustment.</p>
<p>Note that <cite>other</cite> is not necessarily the same type as <cite>self</cite>.</p>
</dd></dl>
<dl class="method">
<dt id="BarValue.periodic">
<tt class="descname">periodic</tt><big>(</big><em>self</em>, <em>st</em><big>)</big><a class="headerlink" href="#BarValue.periodic" title="Permalink to this definition">¶</a></dt>
<dd><p>This method is called once at the start of each interaction. If
it returns a number of seconds, it will be called before that
many seconds elapse, but it might be called sooner. It is
called after get_adjustment.</p>
<p>It can be used to update the value of the bar over time, like
<a class="reference internal" href="screen_actions.html#AnimatedValue" title="AnimatedValue"><tt class="xref py py-func docutils literal"><span class="pre">AnimatedValue()</span></tt></a> does. To do this, get_adjustment should
store the adjustment, and periodic should calle the
adjustment's changed method.</p>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="modes.html" title="Modes"
>next</a> |</li>
<li class="right" >
<a href="trans_trans_python.html" title="Transforms and Transitions in Python"
>previous</a> |</li>
<li> <img src="_static/logo.png" width=19 height=21 align=center>
<li> <a href="http://www.renpy.org/">Ren'Py Home</a> |
<li><a href="index.html">Ren'Py Documentation</a></li>
</ul>
</div>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1', {language : 'en' });
google.setOnLoadCallback(function() {
var customSearchControl = new google.search.CustomSearchControl('012476843541036121001:gx3sqkoaxkm');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
var options = new google.search.DrawOptions();
options.enableSearchboxOnly("http://www.google.com/cse?cx=012476843541036121001:gx3sqkoaxkm");
customSearchControl.draw('cse-search-form', options);
}, true);
</script>
</body>
</html>
|