cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
D_G
D_G
Level II

(Custom) Python GUI executed in JMP

Hi everyone,

 

I have a custom python package which uses GUIs for getting the user input. I now want to execute this package from within JMP18.

PY_SCRIPT = "
from mydummy.util import jmp
from mydummy.request import this_data
df = this_data().GUI()
jmp_source = jmp.df2jmp(df, 'MY DT')
";	
			
EXECUTE = Python Execute({}, {jmp_source}, PY_SCRIPT);
					
If(EXECUTE == 0,					
	DT = Eval(Parse(jmp_source));
,
	DT = New Table();
);

In general this script works. It creates the GUI, processes the data in python, converts it to a JMP-Table-Script and from there on i can use JSL as usual for data anylsis/graphics.

 

However, Python Execute (as well as Run Programm) allways freezes everything in JMP. So, when the GUI is open and the python code is running I can't do anything in JMP anymore. Is there a way to start a new instance of the '~JMP\JMPPRO\18\jmp_python.exe' instance?

I also tried a python script using subprocess.Popen. If i wait for the return I do have the same issues.

My GUI needs the main thread, so threading is also not possible - somehow I need to create a new ~jmp_python.exe instance or jsl can handle it.

Any suggestions? Is that possible?

Thx

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: (Custom) Python GUI executed in JMP

RunProgram freezes JMP because, without a ReadFunction, it collects all the output before returning. It can also be used with a ReadFunction that is called when JMP is idle, or during a wait(0), allowing JMP to do other work as long as there is some idle time.Make a Video in JMP with FFmpeg  has an example of a simple ReadFunction that reads from the external program and writes what it read to the JMP log.

 

Craige

View solution in original post

2 REPLIES 2

Re: (Custom) Python GUI executed in JMP

JMP Python Integration is running on the main thread, which is why it your UI takes over and blocks JMP.  You can try subprocess to specify and launch the a command line launched copy of jmp_python.exe.  That's why the jmp.PYTHON_EXE and jmp.PYTHONW_EXE variables exist.  ( I think the PYTHONW_EXE may be 19+ ).  But from the subprocess you will not be able to utilize the jmp package.

 

Other issues you may find running a Python GUI is it takes over mainloop and when the last dialog closes may cause JMP to crash, because exiting the Python GUI mainloop can take out menu items, window handles,.... that JMP depends on.  It is precarious, as your are attempting to load a different UI toolkit via Python which is embedded within a GUI application...

 

I believe at present the best way to do this is to write the GUI using JSL created dialogs and windows which can be called from Python using jmp.run_jsl.  You can this in the pyDigest.py sample script where a JSL Directory Picker is used to get the path to a directory.

 

jmp.run_jsl('''
localPath = Pick Directory("Choose Directory to checksum");
// Pick Directory on windows returns a leading / use Convert File Path()
If( Host is("Windows"),
    localpath = Convert File Path( localPath, windows )
);

Using JMP's dialog and window features is compatible.  We are investigating the external UI issue.

Craige_Hales
Super User

Re: (Custom) Python GUI executed in JMP

RunProgram freezes JMP because, without a ReadFunction, it collects all the output before returning. It can also be used with a ReadFunction that is called when JMP is idle, or during a wait(0), allowing JMP to do other work as long as there is some idle time.Make a Video in JMP with FFmpeg  has an example of a simple ReadFunction that reads from the external program and writes what it read to the JMP log.

 

Craige

Recommended Articles