/usr/share/doc/python-urwid/html/reference/signals.html is in python-urwid 1.3.1-2+b1.
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 | <!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>Signal Functions — Urwid 1.3.1</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.3.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>
<script type="text/javascript" src="../_static/sidebar.js"></script>
<link rel="top" title="Urwid 1.3.1" href="../index.html" />
<link rel="up" title="Urwid Reference" href="index.html" />
<link rel="next" title="Global Settings" href="global_settings.html" />
<link rel="prev" title="List Walker Classes" href="list_walkers.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="global_settings.html" title="Global Settings"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="list_walkers.html" title="List Walker Classes"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Urwid 1.3.1</a> »</li>
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Urwid Reference</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="signal-functions">
<h1>Signal Functions<a class="headerlink" href="#signal-functions" title="Permalink to this headline">¶</a></h1>
<p>The <code class="xref py py-func docutils literal"><span class="pre">urwid.*_signal()</span></code> functions use a shared Signals object instance
for tracking registered and connected signals. There is no reason to
instantiate your own Signals object.</p>
<dl class="function">
<dt id="urwid.connect_signal">
<code class="descclassname">urwid.</code><code class="descname">connect_signal</code><span class="sig-paren">(</span><em>obj</em>, <em>name</em>, <em>callback</em>, <em>user_arg=None</em>, <em>weak_args=None</em>, <em>user_args=None</em><span class="sig-paren">)</span><a class="headerlink" href="#urwid.connect_signal" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="urwid.Signals.connect">
<code class="descclassname">Signals.</code><code class="descname">connect</code><span class="sig-paren">(</span><em>obj</em>, <em>name</em>, <em>callback</em>, <em>user_arg=None</em>, <em>weak_args=None</em>, <em>user_args=None</em><span class="sig-paren">)</span><a class="headerlink" href="#urwid.Signals.connect" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>obj</strong> (<em>object</em>) – the object sending a signal</li>
<li><strong>name</strong> (<em>signal name</em>) – the signal to listen for, typically a string</li>
<li><strong>callback</strong> (<em>function</em>) – the function to call when that signal is sent</li>
<li><strong>user_arg</strong> – deprecated additional argument to callback (appended
after the arguments passed when the signal is
emitted). If None no arguments will be added.
Don’t use this argument, use user_args instead.</li>
<li><strong>weak_args</strong> (<em>iterable</em>) – <p>additional arguments passed to the callback
(before any arguments passed when the signal
is emitted and before any user_args).</p>
<p>These arguments are stored as weak references
(but converted back into their original value
before passing them to callback) to prevent
any objects referenced (indirectly) from
weak_args from being kept alive just because
they are referenced by this signal handler.</p>
<p>Use this argument only as a keyword argument,
since user_arg might be removed in the future.</p>
</li>
<li><strong>user_args</strong> (<em>iterable</em>) – <p>additional arguments to pass to the callback,
(before any arguments passed when the signal
is emitted but after any weak_args).</p>
<p>Use this argument only as a keyword argument,
since user_arg might be removed in the future.</p>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>When a matching signal is sent, callback will be called. The
arguments it receives will be the user_args passed at connect
time (as individual arguments) followed by all the positional
parameters sent with the signal.</p>
<p>As an example of using weak_args, consider the following snippet:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">urwid</span>
<span class="gp">>>> </span><span class="n">debug</span> <span class="o">=</span> <span class="n">urwid</span><span class="o">.</span><span class="n">Text</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span>
<span class="gp">>>> </span><span class="k">def</span> <span class="nf">handler</span><span class="p">(</span><span class="n">widget</span><span class="p">,</span> <span class="n">newtext</span><span class="p">):</span>
<span class="gp">... </span> <span class="n">debug</span><span class="o">.</span><span class="n">set_text</span><span class="p">(</span><span class="s2">"Edit widget changed to </span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">newtext</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">edit</span> <span class="o">=</span> <span class="n">urwid</span><span class="o">.</span><span class="n">Edit</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">key</span> <span class="o">=</span> <span class="n">urwid</span><span class="o">.</span><span class="n">connect_signal</span><span class="p">(</span><span class="n">edit</span><span class="p">,</span> <span class="s1">'change'</span><span class="p">,</span> <span class="n">handler</span><span class="p">)</span>
</pre></div>
</div>
<p>If you now build some interface using “edit” and “debug”, the
“debug” widget will show whatever you type in the “edit” widget.
However, if you remove all references to the “debug” widget, it
will still be kept alive by the signal handler. This because the
signal handler is a closure that (implicitly) references the
“edit” widget. If you want to allow the “debug” widget to be
garbage collected, you can create a “fake” or “weak” closure
(it’s not really a closure, since it doesn’t reference any
outside variables, so it’s just a dynamic function):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">debug</span> <span class="o">=</span> <span class="n">urwid</span><span class="o">.</span><span class="n">Text</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span>
<span class="gp">>>> </span><span class="k">def</span> <span class="nf">handler</span><span class="p">(</span><span class="n">weak_debug</span><span class="p">,</span> <span class="n">widget</span><span class="p">,</span> <span class="n">newtext</span><span class="p">):</span>
<span class="gp">... </span> <span class="n">weak_debug</span><span class="o">.</span><span class="n">set_text</span><span class="p">(</span><span class="s2">"Edit widget changed to </span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">newtext</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">edit</span> <span class="o">=</span> <span class="n">urwid</span><span class="o">.</span><span class="n">Edit</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">key</span> <span class="o">=</span> <span class="n">urwid</span><span class="o">.</span><span class="n">connect_signal</span><span class="p">(</span><span class="n">edit</span><span class="p">,</span> <span class="s1">'change'</span><span class="p">,</span> <span class="n">handler</span><span class="p">,</span> <span class="n">weak_args</span><span class="o">=</span><span class="p">[</span><span class="n">debug</span><span class="p">])</span>
</pre></div>
</div>
<p>Here the weak_debug parameter in print_debug is the value passed
in the weak_args list to connect_signal. Note that the
weak_debug value passed is not a weak reference anymore, the
signals code transparently dereferences the weakref parameter
before passing it to print_debug.</p>
<p>Returns a key associated by this signal handler, which can be
used to disconnect the signal later on using
urwid.disconnect_signal_by_key. Alternatively, the signal
handler can also be disconnected by calling
urwid.disconnect_signal, which doesn’t need this key.</p>
</dd></dl>
<dl class="function">
<dt id="urwid.disconnect_by_key">
<code class="descclassname">urwid.</code><code class="descname">disconnect_by_key</code><span class="sig-paren">(</span><em>obj</em>, <em>name</em>, <em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#urwid.disconnect_by_key" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="urwid.Signals.disconnect_by_key">
<code class="descclassname">Signals.</code><code class="descname">disconnect_by_key</code><span class="sig-paren">(</span><em>obj</em>, <em>name</em>, <em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#urwid.Signals.disconnect_by_key" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>obj</strong> (<em>object</em>) – the object to disconnect the signal from</li>
<li><strong>name</strong> (<em>signal name</em>) – the signal to disconnect, typically a string</li>
<li><strong>key</strong> (<em>Key</em>) – the key for this signal handler, as returned by
connect_signal().</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>This function will remove a callback from the list connected
to a signal with connect_signal(). The key passed should be the
value returned by connect_signal().</p>
<p>If the callback is not connected or already disconnected, this
function will simply do nothing.</p>
</dd></dl>
<dl class="function">
<dt id="urwid.disconnect_signal">
<code class="descclassname">urwid.</code><code class="descname">disconnect_signal</code><span class="sig-paren">(</span><em>obj</em>, <em>name</em>, <em>callback</em>, <em>user_arg=None</em>, <em>weak_args=None</em>, <em>user_args=None</em><span class="sig-paren">)</span><a class="headerlink" href="#urwid.disconnect_signal" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="urwid.Signals.disconnect">
<code class="descclassname">Signals.</code><code class="descname">disconnect</code><span class="sig-paren">(</span><em>obj</em>, <em>name</em>, <em>callback</em>, <em>user_arg=None</em>, <em>weak_args=None</em>, <em>user_args=None</em><span class="sig-paren">)</span><a class="headerlink" href="#urwid.Signals.disconnect" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>obj</strong> (<em>object</em>) – the object to disconnect the signal from</li>
<li><strong>name</strong> (<em>signal name</em>) – the signal to disconnect, typically a string</li>
<li><strong>callback</strong> (<em>function</em>) – the callback function passed to connect_signal</li>
<li><strong>user_arg</strong> – the user_arg parameter passed to connect_signal</li>
<li><strong>weak_args</strong> – the weak_args parameter passed to connect_signal</li>
<li><strong>user_args</strong> – the weak_args parameter passed to connect_signal</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>This function will remove a callback from the list connected
to a signal with connect_signal(). The arguments passed should
be exactly the same as those passed to connect_signal().</p>
<p>If the callback is not connected or already disconnected, this
function will simply do nothing.</p>
</dd></dl>
<dl class="function">
<dt id="urwid.register_signal">
<code class="descclassname">urwid.</code><code class="descname">register_signal</code><span class="sig-paren">(</span><em>sig_cls</em>, <em>signals</em><span class="sig-paren">)</span><a class="headerlink" href="#urwid.register_signal" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="urwid.Signals.register">
<code class="descclassname">Signals.</code><code class="descname">register</code><span class="sig-paren">(</span><em>sig_cls</em>, <em>signals</em><span class="sig-paren">)</span><a class="headerlink" href="#urwid.Signals.register" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>sig_class</strong> (<em>class</em>) – the class of an object that will be sending signals</li>
<li><strong>signals</strong> (<em>signal names</em>) – a list of signals that may be sent, typically each
signal is represented by a string</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>This function must be called for a class before connecting any
signal callbacks or emiting any signals from that class’ objects</p>
</dd></dl>
<dl class="function">
<dt id="urwid.emit_signal">
<code class="descclassname">urwid.</code><code class="descname">emit_signal</code><span class="sig-paren">(</span><em>obj</em>, <em>name</em>, <em>*args</em><span class="sig-paren">)</span><a class="headerlink" href="#urwid.emit_signal" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="urwid.Signals.emit">
<code class="descclassname">Signals.</code><code class="descname">emit</code><span class="sig-paren">(</span><em>obj</em>, <em>name</em>, <em>*args</em><span class="sig-paren">)</span><a class="headerlink" href="#urwid.Signals.emit" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>obj</strong> (<em>object</em>) – the object sending a signal</li>
<li><strong>name</strong> (<em>signal name</em>) – the signal to send, typically a string</li>
<li><strong>*args</strong> – zero or more positional arguments to pass to the signal
callback functions</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>This function calls each of the callbacks connected to this signal
with the args arguments as positional parameters.</p>
<p>This function returns True if any of the callbacks returned True.</p>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../index.html">
<img class="logo" src="../_static/urwid-logo.png" alt="Logo"/>
</a></p><h3>Table of contents</a></h3>
<ul><li><a href="index.html">Reference</a></li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="list_walkers.html"
title="previous chapter">List Walker Classes</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="global_settings.html"
title="next chapter">Global Settings</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/reference/signals.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="global_settings.html" title="Global Settings"
>next</a> |</li>
<li class="right" >
<a href="list_walkers.html" title="List Walker Classes"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Urwid 1.3.1</a> »</li>
<li class="nav-item nav-item-1"><a href="index.html" >Urwid Reference</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2014, Ian Ward et al.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.6.
</div>
</body>
</html>
|