3.7.5.50 Python(object)

LabTalk Object Type:

Utility Object


The Python object provides script access for running basic Python commands and exchange data with Python console.

Methods:

Method Description
Python.Init()

Initiate the Python application.

Python.chk(strCommand)

Check and ask user to install Python packages. Return
0: All OK
1: Installation needed and initiated
2. Embedded python not installed
3. No internet connection or user refused to install

Python.Exec(strCommand)

Execute one or multiple Python command lines via string strCommand.

Python.Send(OriginRange, PyObjectName)

Send Origin data range OriginRange to Python as object PyObjectName.

Python.Receive(OriginRange, PyObjectName)

Receive Python object as Origin data range OriginRange.

Python.GetReal(LabTalkVar, PyObjectName)

Assign the numeric value of Python object PyObjectName to Origin variable LabTalkVar.

Python.SetReal(LabTalkVar, PyObjectName)

Assign the numeric value of Origin variable LabTalkVar to Python object PyObjectName.

Python.GetStr(LabTalkVar, PyObjectName)

Assign the string value of Python object PyObjectName to Origin string variable LabTalkVar.

Python.SetStr(LabTalkVar, PyObjectName)

Assign the string value of Origin string variable LabTalkVar to Python object PyObjectName.

Python.LTwd$ Python functions can be defined in a .py file and called from LabTalk, including from the Script Window, button objects and Set Values dialog. The default working directory for such files is the User Files Folder (UFF). Use this property to set a different working directory. Property saved to Origin.ini in the UFF.
Python.LTwf$ Used to name the Python file containing functions to be called by LabTalk. By setting this property, you can omit file name. Property saved to Origin.ini in the User Files Folder.

Example

// set a new working directory for Python functions
Python.LTwd$="D:\Python"; 
// search "myfuncs.py" for function "sort()" 
col(b) = py.myfuncs.sort(col(a));
// set working file name and search it for function sort()"
Python.LTwf$=myfuncs.py;
col(b) = py.sort(col(a));
i=Python.chk("pandas cv2(opencv-python)");

Please view this page for additional examples.