<!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>Module: core.events — IPython 2.3.0 documentation</title> <link rel="stylesheet" href="../../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '2.3.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="IPython 2.3.0 documentation" href="../../index.html" /> <link rel="up" title="The IPython API" href="../index.html" /> <link rel="next" title="Module: core.excolors" href="IPython.core.excolors.html" /> <link rel="prev" title="Module: core.error" href="IPython.core.error.html" /> </head> <body> <div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px"> <a href="http://ipython.org/"><img src="../../_static/logo.png" border="0" alt="IPython Documentation"/></a> </div> <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="../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="IPython.core.excolors.html" title="Module: core.excolors" accesskey="N">next</a> |</li> <li class="right" > <a href="IPython.core.error.html" title="Module: core.error" accesskey="P">previous</a> |</li> <li><a href="http://ipython.org">home</a>| </li> <li><a href="../../search.html">search</a>| </li> <li><a href="../../index.html">documentation </a> »</li> <li><a href="../index.html" accesskey="U">The IPython API</a> »</li> </ul> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Module: <tt class="docutils literal"><span class="pre">core.events</span></tt></a><ul> <li><a class="reference internal" href="#class">1 Class</a></li> <li><a class="reference internal" href="#functions">5 Functions</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="IPython.core.error.html" title="previous chapter">Module: <tt class="docutils literal"><span class="pre">core.error</span></tt></a></p> <h4>Next topic</h4> <p class="topless"><a href="IPython.core.excolors.html" title="next chapter">Module: <tt class="docutils literal"><span class="pre">core.excolors</span></tt></a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../../_sources/api/generated/IPython.core.events.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <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="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-IPython.core.events"> <span id="module-core-events"></span><h1>Module: <tt class="xref py py-mod docutils literal"><span class="pre">core.events</span></tt><a class="headerlink" href="#module-IPython.core.events" title="Permalink to this headline">¶</a></h1> <p>Infrastructure for registering and firing callbacks on application events.</p> <p>Unlike <a class="reference internal" href="IPython.core.hooks.html#module-IPython.core.hooks" title="IPython.core.hooks"><tt class="xref py py-mod docutils literal"><span class="pre">IPython.core.hooks</span></tt></a>, which lets end users set single functions to be called at specific times, or a collection of alternative methods to try, callbacks are designed to be used by extension authors. A number of callbacks can be registered for the same event without needing to be aware of one another.</p> <p>The functions defined in this module are no-ops indicating the names of available events and the arguments which will be passed to them.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">This API is experimental in IPython 2.0, and may be revised in future versions.</p> </div> <div class="section" id="class"> <h2>1 Class<a class="headerlink" href="#class" title="Permalink to this headline">¶</a></h2> <dl class="class"> <dt id="IPython.core.events.EventManager"> <em class="property">class </em><tt class="descclassname">IPython.core.events.</tt><tt class="descname">EventManager</tt><big>(</big><em>shell</em>, <em>available_events</em><big>)</big><a class="headerlink" href="#IPython.core.events.EventManager" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference external" href="http://docs.python.org/2/library/functions.html#object" title="(in Python v2.7)"><tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></a></p> <p>Manage a collection of events and a sequence of callbacks for each.</p> <p>This is attached to <a class="reference internal" href="IPython.core.interactiveshell.html#IPython.core.interactiveshell.InteractiveShell" title="IPython.core.interactiveshell.InteractiveShell"><tt class="xref py py-class docutils literal"><span class="pre">InteractiveShell</span></tt></a> instances as an <tt class="docutils literal"><span class="pre">events</span></tt> attribute.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">This API is experimental in IPython 2.0, and may be revised in future versions.</p> </div> <dl class="method"> <dt id="IPython.core.events.EventManager.__init__"> <tt class="descname">__init__</tt><big>(</big><em>shell</em>, <em>available_events</em><big>)</big><a class="headerlink" href="#IPython.core.events.EventManager.__init__" title="Permalink to this definition">¶</a></dt> <dd><p>Initialise the <tt class="xref py py-class docutils literal"><span class="pre">CallbackManager</span></tt>.</p> <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"><p class="first"><strong>shell</strong></p> <blockquote> <div><p>The <a class="reference internal" href="IPython.core.interactiveshell.html#IPython.core.interactiveshell.InteractiveShell" title="IPython.core.interactiveshell.InteractiveShell"><tt class="xref py py-class docutils literal"><span class="pre">InteractiveShell</span></tt></a> instance</p> </div></blockquote> <p><strong>available_callbacks</strong></p> <blockquote class="last"> <div><p>An iterable of names for callback events.</p> </div></blockquote> </td> </tr> </tbody> </table> </dd></dl> <dl class="method"> <dt id="IPython.core.events.EventManager.register"> <tt class="descname">register</tt><big>(</big><em>event</em>, <em>function</em><big>)</big><a class="headerlink" href="#IPython.core.events.EventManager.register" title="Permalink to this definition">¶</a></dt> <dd><p>Register a new event callback</p> <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"><p class="first"><strong>event</strong> : str</p> <blockquote> <div><p>The event for which to register this callback.</p> </div></blockquote> <p><strong>function</strong> : callable</p> <blockquote> <div><p>A function to be called on the given event. It should take the same parameters as the appropriate callback prototype.</p> </div></blockquote> </td> </tr> <tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first"><strong>TypeError</strong></p> <blockquote> <div><p>If <tt class="docutils literal"><span class="pre">function</span></tt> is not callable.</p> </div></blockquote> <p><strong>KeyError</strong></p> <blockquote class="last"> <div><p>If <tt class="docutils literal"><span class="pre">event</span></tt> is not one of the known events.</p> </div></blockquote> </td> </tr> </tbody> </table> </dd></dl> <dl class="method"> <dt id="IPython.core.events.EventManager.reset"> <tt class="descname">reset</tt><big>(</big><em>event</em><big>)</big><a class="headerlink" href="#IPython.core.events.EventManager.reset" title="Permalink to this definition">¶</a></dt> <dd><p>Clear all callbacks for the given event.</p> </dd></dl> <dl class="method"> <dt id="IPython.core.events.EventManager.reset_all"> <tt class="descname">reset_all</tt><big>(</big><big>)</big><a class="headerlink" href="#IPython.core.events.EventManager.reset_all" title="Permalink to this definition">¶</a></dt> <dd><p>Clear all callbacks for all events.</p> </dd></dl> <dl class="method"> <dt id="IPython.core.events.EventManager.trigger"> <tt class="descname">trigger</tt><big>(</big><em>event</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#IPython.core.events.EventManager.trigger" title="Permalink to this definition">¶</a></dt> <dd><p>Call callbacks for <tt class="docutils literal"><span class="pre">event</span></tt>.</p> <p>Any additional arguments are passed to all callbacks registered for this event. Exceptions raised by callbacks are caught, and a message printed.</p> </dd></dl> <dl class="method"> <dt id="IPython.core.events.EventManager.unregister"> <tt class="descname">unregister</tt><big>(</big><em>event</em>, <em>function</em><big>)</big><a class="headerlink" href="#IPython.core.events.EventManager.unregister" title="Permalink to this definition">¶</a></dt> <dd><p>Remove a callback from the given event.</p> </dd></dl> </dd></dl> </div> <div class="section" id="functions"> <h2>5 Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h2> <dl class="function"> <dt id="IPython.core.events.pre_execute"> <tt class="descclassname">IPython.core.events.</tt><tt class="descname">pre_execute</tt><big>(</big><big>)</big><a class="headerlink" href="#IPython.core.events.pre_execute" title="Permalink to this definition">¶</a></dt> <dd><p>Fires before code is executed in response to user/frontend action.</p> <p>This includes comm and widget messages and silent execution, as well as user code cells.</p> </dd></dl> <dl class="function"> <dt id="IPython.core.events.pre_run_cell"> <tt class="descclassname">IPython.core.events.</tt><tt class="descname">pre_run_cell</tt><big>(</big><big>)</big><a class="headerlink" href="#IPython.core.events.pre_run_cell" title="Permalink to this definition">¶</a></dt> <dd><p>Fires before user-entered code runs.</p> </dd></dl> <dl class="function"> <dt id="IPython.core.events.post_execute"> <tt class="descclassname">IPython.core.events.</tt><tt class="descname">post_execute</tt><big>(</big><big>)</big><a class="headerlink" href="#IPython.core.events.post_execute" title="Permalink to this definition">¶</a></dt> <dd><p>Fires after code is executed in response to user/frontend action.</p> <p>This includes comm and widget messages and silent execution, as well as user code cells.</p> </dd></dl> <dl class="function"> <dt id="IPython.core.events.post_run_cell"> <tt class="descclassname">IPython.core.events.</tt><tt class="descname">post_run_cell</tt><big>(</big><big>)</big><a class="headerlink" href="#IPython.core.events.post_run_cell" title="Permalink to this definition">¶</a></dt> <dd><p>Fires after user-entered code runs.</p> </dd></dl> <dl class="function"> <dt id="IPython.core.events.shell_initialized"> <tt class="descclassname">IPython.core.events.</tt><tt class="descname">shell_initialized</tt><big>(</big><em>ip</em><big>)</big><a class="headerlink" href="#IPython.core.events.shell_initialized" title="Permalink to this definition">¶</a></dt> <dd><p>Fires after initialisation of <a class="reference internal" href="IPython.core.interactiveshell.html#IPython.core.interactiveshell.InteractiveShell" title="IPython.core.interactiveshell.InteractiveShell"><tt class="xref py py-class docutils literal"><span class="pre">InteractiveShell</span></tt></a>.</p> <p>This is before extensions and startup scripts are loaded, so it can only be set by subclassing.</p> <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"><p class="first"><strong>ip</strong> : <a class="reference internal" href="IPython.core.interactiveshell.html#IPython.core.interactiveshell.InteractiveShell" title="IPython.core.interactiveshell.InteractiveShell"><tt class="xref py py-class docutils literal"><span class="pre">InteractiveShell</span></tt></a></p> <blockquote class="last"> <div><p>The newly initialised shell.</p> </div></blockquote> </td> </tr> </tbody> </table> </dd></dl> </div> </div> </div> </div> </div> <div class="clearer"></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="../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="IPython.core.excolors.html" title="Module: core.excolors" >next</a> |</li> <li class="right" > <a href="IPython.core.error.html" title="Module: core.error" >previous</a> |</li> <li><a href="http://ipython.org">home</a>| </li> <li><a href="../../search.html">search</a>| </li> <li><a href="../../index.html">documentation </a> »</li> <li><a href="../index.html" >The IPython API</a> »</li> </ul> </div> <div class="footer"> © Copyright The IPython Development Team. Last updated on Jul 14, 2015. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3. </div> </body> </html>