Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
scripting:python [2014/02/09 01:50] – external edit 127.0.0.1scripting:python [2018/05/11 16:01] (current) admin
Line 1: Line 1:
 ====== Python Scripts ====== ====== Python Scripts ======
  
-You can also use Python for scripting of HippoEDIT. It is not so straight forward as with JavaScript or VB Script but still possible. +You can also use Python for scripting of HippoEDIT. It is not so straightforward as with JavaScript or VB Script but still possible. 
  
 To start writing your tool or service scripts in Python, you need to do following steps: To start writing your tool or service scripts in Python, you need to do following steps:
-  - **Install Python**. There are at least two installation of Python available. Official one, that can be downloaded from [[http://www.python.org/download/|python.org]] or ActivePython installation (free Community Edition) from [[http://www.activestate.com/activepython/downloads|ActiveState web site]]. Download one for your version of Windows version of HippoEDIT (you need x64 bit version for HippoEDIT x64) and install it. Now you can execute python scripts.  +  - **Install Python**. There are at least two installations of Python available. Official one, that can be downloaded from [[https://www.python.org/downloads/windows/|python.org]] or ActivePython installation (free Community Edition) from [[http://www.activestate.com/activepython/downloads|ActiveState web site]]. Download one fitting your version of Windows and your HippoEDIT architecture (you need x64 bit version for HippoEDIT x64) and install it. Now you can execute python scripts.  
-  - **Install Python for Windows extensions**. To be able to use Python for application scripting (with Active Scripting technology), you need to install //Python for Windows extensions// from [[http://sourceforge.net/projects/pywin32/files/pywin32/|Source Forge project page]]. Select latest build and download extension version corresponding to version of Python you have installed (for example //pywin32-218.win-amd64-py2.7.exe//). Install it, agree on everything.  +  - **Install Python for Windows extensions**. To be able to use Python for application scripting (with Active Scripting technology), you need to install //Python for Windows extensions// from [[https://github.com/mhammond/pywin32/releases|GitHub project page]]. Select the latest build and download extension version corresponding to the version of Python you have installed (for example //pywin32-223.win-amd64-py3.6.exe//). Install it, agree on everything.  
-  - **Register Python as Scripting Engine**. After installation of the extension, in Python folder (for example C:\Python27) find file //\lib\site-packages\win32comext\axscript\client\pyscript.py// and execute it by double clicking. It shell result in UAC prompt (agree on it) and output like "Registered: Python"+  - **Register Python as Scripting Engine**. After installation of the extension, in Python folder (for example C:\Users\<user_name>\AppData\Local\Programs\Python\Python36\ ) find file //\lib\site-packages\win32comext\axscript\client\pyscript.py// and execute it by double-clicking. It shall result in UAC prompt (agree on it) and output like "Registered: Python"
   - If all went fine, now you are able to run/write Python scripts/plug-ins in HippoEDIT.   - If all went fine, now you are able to run/write Python scripts/plug-ins in HippoEDIT.
  
Line 21: Line 21:
  
 ==== Include and Imports ==== ==== Include and Imports ====
-Looks like Python implementation does not support modules in other languages to be inserted into global scope... So, you can not use HE functions for [[scripting:includes-imports|including/importing of files]] (as include/import directives or __include/__import commands). But fortunately Python has his own functions for python module including. +Looks like Python implementation does not support modules in other languages to be inserted into global scope... So, you can not use HE functions for [[scripting:includes-imports|including/importing of files]] (as include/import directives or __include/__import commands). But fortunatelyPython has his own functions for python module including. 
  
 This limitation is also result that HippoEDIT constants (like //eMessageTypeInfo//), defined in file <[[options:user_directory|UserDirectory]]>/scripts/he_constants.js, which are normally included in the scope are not recognized :-\ . So, just redefine them in your Python file, coping from he_constants.js. It is very unlikely that they will be changed.  This limitation is also result that HippoEDIT constants (like //eMessageTypeInfo//), defined in file <[[options:user_directory|UserDirectory]]>/scripts/he_constants.js, which are normally included in the scope are not recognized :-\ . So, just redefine them in your Python file, coping from he_constants.js. It is very unlikely that they will be changed.