The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Activate Python Script Using LabTalk

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
hrorigin Posted - 02/20/2023 : 1:56:57 PM
Origin Ver. and Service Release: 10.0.0.154 OriginPro 2023
Operating System: Windows 10

Hi!

I was trying to set up buttons in my origin project such that clicking on it would activate a Python script. I found the following link that documents how to use LabTalk to activate the Python Script.

https://www.originlab.com/doc/en/LabTalk/ref/Run-obj#Run_Python:

I was trying to set it up such that the LabTalk script would go into the folder the origin exe exists and then go into a subdirectory where the Python files I would like to run would reside.

I tried formatting the first line of the LabTalk script like this:

string file_path$ = system.PATH.PROGRAM$ + "\MyFolder\";

But even when I had the same name for the folder in the directory with the wanted Python file the project would return that the directory was not found. The rest of the LabTalk script looks the same as in the URL but with the name of my python file instead.

Any advice is appreciated

Thank you in advance
2   L A T E S T    R E P L I E S    (Newest First)
hrorigin Posted - 02/21/2023 : 08:48:07 AM
Thank you for the help James!

I was also able to find this solution using Labtalk in the same script window that you could put the Python script in.

run.python("C:\PathTo\MyFile\MyPythonScript.py", 2);


Did not know you could put the path to the file when using "2" as the second argument. Very useful if someone wants their python scripts all in one file than within the Origin project.
YimingChen Posted - 02/20/2023 : 5:03:51 PM
You can run Python script by clicking a button. Please check this page:
https://www.originlab.com/doc/en/python/tools/Run-Python-from-Graph-Object

By the way, if you run the following script in the script window, there is an extra '\'.

string file_path$ = system.PATH.PROGRAM$ + "\MyFolder\";
file_path$=;


James

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000