Wiki page
[Usage] by
gwlester
2018-02-04 19:43:28.
D 2018-02-04T19:43:28.835
L Usage
P 2a21c286e1eb46ac6e892fb5b377fde8c46442adae80ed2d167b8add0e65cca0
U gwlester
W 2880
<h1>Usage</h1>
<h2>package require pyman</h2>
<h2><br>
</h2>
<h2>pyman addPath <i>pathName</i></h2>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div>
<span style="font-size: 13.3333px;">This will add <i><b>pathName</b></i> to
the list of directories that Python searches for where to find Python module
files to be imported. This is roughly akin to <b>lappend</b> of a
directory to Tcl's <b>auto_path</b> variable or doing a ::tcl::tm::path add to
add a directory to the directories searched for module files.</span><i><br>
</i></div></blockquote>
<h2><br>
</h2>
<h2>pyman import <i>?-namespace nsName?</i> <i>pythonModuleFileName</i></h2>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div>This will import the Python module and analize the module using the Python
introspection tools. The following will be done:</div>
<div>
<ol>
<li>A namespace to contail the Tcl functions and class wrapers for the
functions and class will be created. If the <b>-namesapce</b> option
was present than its value, <i>nsName</i>, will be used. Otherwise the
namespace will be named <b>::pyman::</b><i style="font-weight: bold;">pythonModuleName</i> where
<i>pythonModuleName</i> is the name of the Python module that was
imported.</li>
<li>For each function found in the module, a Tcl wrapper function will be
generated that take the same arguments and will call the Python function and
return its results.</li>
<li>For each class found in the module, a TclOO wrapper class will be
generated. This class will have the same methods with the same arguments
as the public methods in the Python class. </li>
<li>Creation of a new TclOO object of this class will result in a Python object
of the same class being created. </li>
<ul>
<li><u><font color="#ff0000">(Not yet implemented) Calls to class methods of
the class will call static methods of the Python class.</font></u></li>
<li>Calls to instance methods of the class will call instance methods of the
corresponding Python object instances.</li>
<li>Instance attributes can be accessed via the following special methods:</li>
<ul>
<li><b>_attributes</b> -- Get a list of attributes and their allowed values. </li>
<li><b>_getAttribute</b> <b><i>attributeName</i></b> -- Return the value of the
named attribute.</li>
<li><b>_setAttribute</b> <b><i>attributeName value</i></b> -- Set the named
attribute to the specified value. (Note: not all attributes can be modified).</li>
</ul>
<li>The Tcl programmer is allowed to add additional methods and/
<span style="font-size: 13.3333px;">or variables </span>to the
<span style="font-size: 13.3333px;">TclOO</span> class and/or instances of
the class, these will only be visble from Tcl.<br>
</li>
</ul>
</ol></div></blockquote>
<pre></pre>
Z 37473ff6adca9c1c31a134ecdc50a0a9