cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
andersonmj2
Level IV

Collecting user input via dialog box in a python script?

I need to add collecting user inputs to an existing older python script (it initially used fixed number and location for files) ... I can get it to somewhat work using the "jmp.run_jsl()" function - it displays the dialog, gets the input and can print it out - but doesn't actually return anything to Python.  I've tried the Python Send and Get commands but the variable remains '0'.

 

I started off just using the sample script for a modal dialog and wrapping it in jmp.run_jsl() - and as noted it pops up the dialog but nothing comes back to Python.

 

I assume it would be more efficient to do it in Python but not sure if that is possible (of course the other option is to rewrite in JSL but need the core code portable for other uses).  Am I missing something?

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Collecting user input via dialog box in a python script?

import jmp

jmp.run_jsl('''
nw = New Window("", << modal, 
	teb = Number Edit Box(10),
	Button Box("OK",
		myval = teb << get;
		Python Send(myval);
	)
);
''');

print(f'{myval=}, myval*100 = {myval*100}');
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Collecting user input via dialog box in a python script?

import jmp

jmp.run_jsl('''
nw = New Window("", << modal, 
	teb = Number Edit Box(10),
	Button Box("OK",
		myval = teb << get;
		Python Send(myval);
	)
);
''');

print(f'{myval=}, myval*100 = {myval*100}');
-Jarmo
andersonmj2
Level IV

Re: Collecting user input via dialog box in a python script?

Thanks very much - works perfectly!