cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar

Creating a GUI with Checkboxes to Trigger File Selection and Data Formatting Functions

am developing a graphical user interface (GUI) that allows users to select one or more options via checkboxes. For each selected option, the GUI should perform the following actions sequentially:

  1. Pick File: Open a file picker dialog to allow the user to select a specific file related to the chosen option.
  2. Format and Save: Process the selected file using a predefined function that formats the data and saves the changes.

Nedd help:

I need help handling scenarios where multiple checkboxes are selected simultaneously, ensuring that each selected option independently triggers its associated functions without conflicts.

I'm unsure how to set up event listeners for each checkbox to trigger the corresponding functions when selected.

Outcome

 

  • Users can select one or more options via checkboxes.
  • Upon selection, for each checked box:
    • A file picker dialog appears for the user to select the relevant file.
    • The selected file is processed by the formatting function.
    • The formatted data is saved appropriately.
  • The GUI remains responsive and provides feedback during and after the operations.

I have attached the code so far with comments where i need help.. also if there is a more elegant solution for gui please share 

 

Thank you

 

Names Default To Here( 1 );
directory_to_collect_data_table = "/C:/Users/";
data_list = {"datatable_1 ", "datatable_2", "datatable_3"};
userInput_dt = Function( {},
	dt = Pick File(
		"3. Pick Up Data Table_Total#1",
		directory_to_collect_data_table,
		{"JMP Files|jmp;jsl;jrn", "All Files|*"},
		1,
		0,
		"",
		"multiple"
	);
	Return( dt );
);
datatable_1func = Function( {dt},
	dt << New Column( "label",
		Character,  // The new column will store character values
		Formula(
			"D" || Substitute( :Extracted_Data, "A", "" )  // Prepend "D" and remove "A"
		)
	);
	dt << Column( "Extracted_Data" ) << Hide( 1 );
	dt:ROW1 << Data Type( Character );
	final_data1 = Data Table( "final_data" );
);

// GUI for selecting and merging files
Userinput_1 = New Window( 
		Panel Box( "Select the datatable",
			Check Box( data_list ),
			Button Box( "Select Files", Userinput_1//add functionality
			//add functionality if datatable_1 is selected then call function datatable_1func ( datatable_1 );
			//whichever check box is selected accordingly a function is called 	
			)
		
		)
	)
);
2 REPLIES 2
jthi
Super User

Re: Creating a GUI with Checkboxes to Trigger File Selection and Data Formatting Functions

You can use << get selected to get the selected items (or << get selected indices if you just want the indices and not values). Then loop over the selection list and perform the actions

Names Default To Here(1);

nw = New Window("Example",
	cb = Check Box(
		{"One", "Two", "Three"}
	),
	Button Box("Go",
		For Each({sel}, cb << get selected,
			Match(sel,
				"One", Show("FIRST"),
				"Two", Show("SECOND"),
				"Three", Show("THIRD")
			);
		);
	);
);

Construct Display Boxes for New Windows (jmp.com)

-Jarmo

Re: Creating a GUI with Checkboxes to Trigger File Selection and Data Formatting Functions

You can associate a function with the check box. It is called whenever the user interacts with the check box. See Help > Scripting Index:

check box.png