Artifact Content

Artifact c37be4c149fa257724830e6129a8fcbe9365154b8a0cdeff3b4d14d88cb9f555:

Wiki page [Usage] by gwlester 2018-02-05 21:13:36.
D 2018-02-05T21:13:36.011
L Usage
P 64bb67671587b0923a7a31dffa14c08e899f491bcb66b415a0b9290853e8b401
U gwlester
W 3048

<h2>package require pyman</h2>


<h2>pyman&nbsp;addPath <i>pathName</i></h2>

<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">


<span style="font-size: 13.3333px;">This will add <i><b>pathName</b></i>&nbsp;to
the list of directories that Python searches for where to find Python module
files to be imported.&nbsp; 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>


<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>

<li>A namespace to contail the Tcl functions and class wrapers for the
functions and class will be created.&nbsp; If the <b>-namesapce</b>&nbsp;option
was present than its value, <i>nsName</i>, will be used.&nbsp; Otherwise the
namespace will be named <b>::pyman::</b><i style="font-weight: bold;">pythonModuleName</i>&nbsp;where
<i>pythonModuleName</i>&nbsp;is the name of the Python module that was
<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&nbsp; found in the module, a TclOO wrapper class will be
generated.&nbsp; This class will have the same methods with the same arguments
as the public methods in the Python class.&nbsp;&nbsp;</li>
<li>Creation of a new TclOO object of this class will result in a Python object
of the same class being created.&nbsp;&nbsp;</li>
<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>
<li><b>_attributes <i>?pattern?</i></b> -- Get a list of attributes that match
the glob style&nbsp;<i style=""><b>pattern</b>&nbsp;</i>and their allowed
values.&nbsp; &nbsp;The default for <i style="font-weight: bold;">pattern</i>&nbsp;is
<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>
<li>The Tcl programmer is allowed to add additional methods and/

<span style="font-size: 13.3333px;">or variables&nbsp;</span>to the&nbsp;

<span style="font-size: 13.3333px;">TclOO</span>&nbsp;class and/or instances of
the class, these will only be visble from Tcl.<br>

Z 3d0b55a95902087cf6408365eb330fb4