/usr/share/doc/python-gtkmvc-doc/reference/adapters.html is in python-gtkmvc-doc 1.99.1-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Adapters — GTK MVC 1.99.1 documentation</title>
<link rel="stylesheet" href="_static/classic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.99.1',
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="GTK MVC 1.99.1 documentation" href="index.html" />
<link rel="next" title="Observable Properties" href="observable.html" />
<link rel="prev" title="The Controller" href="controller.html" />
</head>
<body role="document">
<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="observable.html" title="Observable Properties"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="controller.html" title="The Controller"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">GTK MVC 1.99.1 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="module-gtkmvc.adapters">
<span id="adapters"></span><h1>Adapters<a class="headerlink" href="#module-gtkmvc.adapters" title="Permalink to this headline">¶</a></h1>
<dl class="class">
<dt>
<em class="property">class </em><code class="descclassname">gtkmvc.adapters.</code><code class="descname">Adapter</code></dt>
<dd></dd></dl>
<dl class="class">
<dt>
<em class="property">class </em><code class="descclassname">gtkmvc.adapters.</code><code class="descname">UserClassAdapter</code></dt>
<dd></dd></dl>
<dl class="class">
<dt>
<em class="property">class </em><code class="descclassname">gtkmvc.adapters.</code><code class="descname">RoUserClassAdapter</code></dt>
<dd></dd></dl>
<dl class="class">
<dt>
<em class="property">class </em><code class="descclassname">gtkmvc.adapters.</code><code class="descname">StaticContainerAdapter</code></dt>
<dd><p>These are shortcuts to classes from modules in this package.</p>
</dd></dl>
<div class="section" id="module-gtkmvc.adapters.basic">
<span id="overwriting-properties"></span><h2>Overwriting properties<a class="headerlink" href="#module-gtkmvc.adapters.basic" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="gtkmvc.adapters.basic.Adapter">
<em class="property">class </em><code class="descclassname">gtkmvc.adapters.basic.</code><code class="descname">Adapter</code><span class="sig-paren">(</span><em>model</em>, <em>prop_name</em>, <em>prop_read=None</em>, <em>prop_write=None</em>, <em>value_error=None</em>, <em>spurious=False</em>, <em>prop_cast=True</em><span class="sig-paren">)</span><a class="headerlink" href="#gtkmvc.adapters.basic.Adapter" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="observer.html#gtkmvc.observer.Observer" title="gtkmvc.observer.Observer"><code class="xref py py-class docutils literal"><span class="pre">gtkmvc.observer.Observer</span></code></a></p>
<p>Creates a new adapter that handles setting of value of a
model single model property when a corresponding widgets set
is changed and viceversa when the property is also
observable.</p>
<p>This class handles only assignments to properties. For other
kinds of setting (e.g. user-defined classes used as
observable properties, containers, etc.) use other types of
Adapters derived from this class.</p>
<p>prop_name is the model’s property name (as a string). It is
possible to use a dotted notation to identify a property
contained into a hierarchy of models. For example ‘a.b.c’
identifies property ‘c’ into model ‘b’ inside model ‘a’,
where model ‘a’ is an attribute of given top level model.
Last name must be an observable or non-observable attribute,
and previous names (if specified) must all refer to
instances of class Model. First name from the left must be
the name of a model instance inside the given model.</p>
<p>prop_{write,read} are two optional functions that apply
custom modifications to the value of the property before
setting and reading it. Both take a value and must return a
transformed value whose type must be compatible with the
type of the property.</p>
<p>value_error can be a function (or a method) to be called
when a ValueError exception occurs while trying to set a
wrong value for the property inside the model. The function
will receive: the adapter, the property name and the value
coming from the widget that offended the model.</p>
<p>spurious controls if the adapter should receive spurious
changes from the model (see spuriousness in class Observer for
further information).</p>
<dl class="method">
<dt id="gtkmvc.adapters.basic.Adapter.connect_widget">
<code class="descname">connect_widget</code><span class="sig-paren">(</span><em>wid</em>, <em>getter=None</em>, <em>setter=None</em>, <em>signal=None</em>, <em>arg=None</em>, <em>update=True</em><span class="sig-paren">)</span><a class="headerlink" href="#gtkmvc.adapters.basic.Adapter.connect_widget" title="Permalink to this definition">¶</a></dt>
<dd><p>Called when the widget is instantiated, and the adapter is
ready to connect the widget and the property inside the
observed model. arg is the (optional) argument that will be
passed when connecting the signal.</p>
<p>getter and setter are the (optional) methods used
for reading and writing the widget’s value. When not
specified, default getter and setter will be guessed by
looking at the widget type the adapter will be connected
with. Guessing is carried out by querying information
specified into module ‘adapters.default’.</p>
<p>Finally, if update is false, the widget will not be updated</p>
</dd></dl>
<dl class="method">
<dt id="gtkmvc.adapters.basic.Adapter.get_property_name">
<code class="descname">get_property_name</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#gtkmvc.adapters.basic.Adapter.get_property_name" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the property the adapter is conected to</p>
</dd></dl>
<dl class="method">
<dt id="gtkmvc.adapters.basic.Adapter.get_widget">
<code class="descname">get_widget</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#gtkmvc.adapters.basic.Adapter.get_widget" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the widget the adapter is conected to</p>
</dd></dl>
<dl class="method">
<dt id="gtkmvc.adapters.basic.Adapter.update_model">
<code class="descname">update_model</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#gtkmvc.adapters.basic.Adapter.update_model" title="Permalink to this definition">¶</a></dt>
<dd><p>Forces the property to be updated from the value hold by
the widget. This method should be called directly by the
user in very unusual conditions.</p>
</dd></dl>
<dl class="method">
<dt id="gtkmvc.adapters.basic.Adapter.update_widget">
<code class="descname">update_widget</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#gtkmvc.adapters.basic.Adapter.update_widget" title="Permalink to this definition">¶</a></dt>
<dd><p>Forces the widget to be updated from the property
value. This method should be called directly by the user
when the property is not observable, or in very unusual
conditions.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="mutating-properties">
<h2>Mutating properties<a class="headerlink" href="#mutating-properties" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="gtkmvc.adapters.basic.UserClassAdapter">
<em class="property">class </em><code class="descclassname">gtkmvc.adapters.basic.</code><code class="descname">UserClassAdapter</code><span class="sig-paren">(</span><em>model</em>, <em>prop_name</em>, <em>getter</em>, <em>setter</em>, <em>prop_read=None</em>, <em>prop_write=None</em>, <em>value_error=None</em>, <em>spurious=False</em><span class="sig-paren">)</span><a class="headerlink" href="#gtkmvc.adapters.basic.UserClassAdapter" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#gtkmvc.adapters.basic.Adapter" title="gtkmvc.adapters.basic.Adapter"><code class="xref py py-class docutils literal"><span class="pre">gtkmvc.adapters.basic.Adapter</span></code></a></p>
<p>This class handles the communication between a widget and a
class instance (possibly observable) that is a property inside
the model. The value to be shown is taken and stored by using a
getter and a setter. getter and setter can be: names of user
class methods, bound or unbound methods of the user class, or a
function that will receive the user class instance and possible
arguments whose number depends on whether it is a getter or a
setter.</p>
</dd></dl>
</div>
<div class="section" id="modifying-immutable-properties">
<h2>Modifying immutable properties<a class="headerlink" href="#modifying-immutable-properties" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="gtkmvc.adapters.basic.RoUserClassAdapter">
<em class="property">class </em><code class="descclassname">gtkmvc.adapters.basic.</code><code class="descname">RoUserClassAdapter</code><span class="sig-paren">(</span><em>model</em>, <em>prop_name</em>, <em>getter</em>, <em>setter</em>, <em>prop_read=None</em>, <em>prop_write=None</em>, <em>value_error=None</em>, <em>spurious=False</em><span class="sig-paren">)</span><a class="headerlink" href="#gtkmvc.adapters.basic.RoUserClassAdapter" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#gtkmvc.adapters.basic.UserClassAdapter" title="gtkmvc.adapters.basic.UserClassAdapter"><code class="xref py py-class docutils literal"><span class="pre">gtkmvc.adapters.basic.UserClassAdapter</span></code></a></p>
<p>This class is for Read-Only user classes. RO classes are those
whose setting methods do not change the instance, but return a
new instance that has been changed accordingly to the setters
semantics. An example is python datetime class, whose replace
method does not change the instance it is invoked on, but
returns a new datetime instance.</p>
<p>This class is likely to be used very rarely.</p>
</dd></dl>
</div>
<div class="section" id="module-gtkmvc.adapters.containers">
<span id="single-adapter-multiple-widgets"></span><h2>Single Adapter, multiple widgets<a class="headerlink" href="#module-gtkmvc.adapters.containers" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="gtkmvc.adapters.containers.StaticContainerAdapter">
<em class="property">class </em><code class="descclassname">gtkmvc.adapters.containers.</code><code class="descname">StaticContainerAdapter</code><span class="sig-paren">(</span><em>model</em>, <em>prop_name</em>, <em>prop_read=None</em>, <em>prop_write=None</em>, <em>value_error=None</em>, <em>spurious=False</em><span class="sig-paren">)</span><a class="headerlink" href="#gtkmvc.adapters.containers.StaticContainerAdapter" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#gtkmvc.adapters.basic.UserClassAdapter" title="gtkmvc.adapters.basic.UserClassAdapter"><code class="xref py py-class docutils literal"><span class="pre">gtkmvc.adapters.basic.UserClassAdapter</span></code></a></p>
<p>This class can be used to bound a set of widgets to a property
that is a container, like a tuple, a list or a map, or in
general a class that implements __getitem__ and __setitem__
methods.</p>
<p>From the other hand, the set of widgets can be a list provided
by the user, or a container widget like a Box, a notebook, etc.
Widgets will be linked by their position when the property is
list-like, or by their name when the property is map-like.</p>
<p>This class supports only properties that are static containers,
i.e. those containers that do not change their length
dynamically. If the container grows up in length, no change will
occur in the view-side.</p>
<dl class="method">
<dt id="gtkmvc.adapters.containers.StaticContainerAdapter.connect_widget">
<code class="descname">connect_widget</code><span class="sig-paren">(</span><em>wid</em>, <em>getters=None</em>, <em>setters=None</em>, <em>signals=None</em>, <em>arg=None</em><span class="sig-paren">)</span><a class="headerlink" href="#gtkmvc.adapters.containers.StaticContainerAdapter.connect_widget" title="Permalink to this definition">¶</a></dt>
<dd><p>Called when the widget is instantiated, and the adapter is
ready to connect the widgets inside it (if a container) or
each widget if wid is a list of widgets. getters and setters
can be None, a function or a list or a map of
functions. signals can be None, a signal name, or a list or
a map of signal names. When maps are used, keys can be
widgets or widget names. The length of the possible lists or
maps must be lesser or equal to the number of widgets that
will be connected.</p>
</dd></dl>
<dl class="method">
<dt id="gtkmvc.adapters.containers.StaticContainerAdapter.update_model">
<code class="descname">update_model</code><span class="sig-paren">(</span><em>idx=None</em><span class="sig-paren">)</span><a class="headerlink" href="#gtkmvc.adapters.containers.StaticContainerAdapter.update_model" title="Permalink to this definition">¶</a></dt>
<dd><p>Updates the value of property at given index. If idx is
None, all controlled indices will be updated. This method
should be called directly by the user in very unusual
conditions.</p>
</dd></dl>
<dl class="method">
<dt id="gtkmvc.adapters.containers.StaticContainerAdapter.update_widget">
<code class="descname">update_widget</code><span class="sig-paren">(</span><em>idx=None</em><span class="sig-paren">)</span><a class="headerlink" href="#gtkmvc.adapters.containers.StaticContainerAdapter.update_widget" title="Permalink to this definition">¶</a></dt>
<dd><p>Forces the widget at given index to be updated from the
property value. If index is not given, all controlled
widgets will be updated. This method should be called
directly by the user when the property is not observable, or
in very unusual conditions.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="module-gtkmvc.adapters.default">
<span id="connecting-automatically"></span><h2>Connecting automatically<a class="headerlink" href="#module-gtkmvc.adapters.default" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="gtkmvc.adapters.default.add_adapter">
<code class="descclassname">gtkmvc.adapters.default.</code><code class="descname">add_adapter</code><span class="sig-paren">(</span><em>widget_class</em>, <em>signal_name</em>, <em>getter</em>, <em>setter</em>, <em>value_type</em><span class="sig-paren">)</span><a class="headerlink" href="#gtkmvc.adapters.default.add_adapter" title="Permalink to this definition">¶</a></dt>
<dd><p>This function can be used to extend at runtime the set of
default adapters. If given widget class which is being added is
already in the default set, it will be substituted by the new one
until the next removal (see remove_adapter).</p>
</dd></dl>
<dl class="function">
<dt id="gtkmvc.adapters.default.remove_adapter">
<code class="descclassname">gtkmvc.adapters.default.</code><code class="descname">remove_adapter</code><span class="sig-paren">(</span><em>widget_class</em><span class="sig-paren">)</span><a class="headerlink" href="#gtkmvc.adapters.default.remove_adapter" title="Permalink to this definition">¶</a></dt>
<dd><p>Removes the given widget class information from the default set
of adapters.</p>
<p>If widget_class had been previously added by using add_adapter,
the added adapter will be removed, restoring possibly previusly
existing adapter(s). Notice that this function will remove only
<em>one</em> adapter about given wiget_class (the first found in order),
even if many are currently stored.</p>
<p>Returns True if one adapter was removed, False if no adapter was
removed.</p>
</dd></dl>
<dl class="function">
<dt id="gtkmvc.adapters.default.search_adapter_info">
<code class="descclassname">gtkmvc.adapters.default.</code><code class="descname">search_adapter_info</code><span class="sig-paren">(</span><em>wid</em><span class="sig-paren">)</span><a class="headerlink" href="#gtkmvc.adapters.default.search_adapter_info" title="Permalink to this definition">¶</a></dt>
<dd><p>Given a widget returns the default tuple found in __def_adapter</p>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Adapters</a><ul>
<li><a class="reference internal" href="#module-gtkmvc.adapters.basic">Overwriting properties</a></li>
<li><a class="reference internal" href="#mutating-properties">Mutating properties</a></li>
<li><a class="reference internal" href="#modifying-immutable-properties">Modifying immutable properties</a></li>
<li><a class="reference internal" href="#module-gtkmvc.adapters.containers">Single Adapter, multiple widgets</a></li>
<li><a class="reference internal" href="#module-gtkmvc.adapters.default">Connecting automatically</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="controller.html"
title="previous chapter">The Controller</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="observable.html"
title="next chapter">Observable Properties</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/adapters.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</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"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="observable.html" title="Observable Properties"
>next</a> |</li>
<li class="right" >
<a href="controller.html" title="The Controller"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">GTK MVC 1.99.1 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2010, Roberto Cavada.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.3.
</div>
</body>
</html>
|