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
dylan-1
Level I

How to live update a panel box?

Hello,

I'm trying to script a user input box in which the available number col edit boxes depends on what the user selects for the radio box. However, the window doesn't update as expected:

 

Names Default To Here( 1 );
SampleConfig = "2 x 2";
		
New Window( "Select Sample Configuration",
	<<Modal, //
	H List Box(
		Panel Box( "Select Sample Configuration",
			rb = Radio Box(
				{"2 x 2", "3 x 3"},
				<<setfunction(
					Function( {this},
						SampleConfig = rb << Get Selected;
						pbox1 << inval;
						pbox1 << updateWindow;
						Print( "Selection Changed!" );
						Print( SampleConfig );
					)
				)
			)
		),
		pbox1 = Panel Box( "Scribe #s",
			If(
				SampleConfig == "3 x 3",
					H List Box(
						"Scribe #s", 

						col1 = Number Col Edit Box( , [1, 4, 7] ),
						col2 = Number Col Edit Box( , [2, 5, 8] ),
						col3 = Number Col Edit Box( , [3, 6, 9] )
					),
				SampleConfig == "2 x 2",
					H List Box(
						"Scribe #s", 

						col1 = Number Col Edit Box( , [1, 3] ),
						col2 = Number Col Edit Box( , [2, 4] )
					),

			)
		)
	)
); 

Any suggestions as to what I'm doing wrong?

 

Thanks,

Dylan

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: How to live update a panel box?

Your If() statement to choose which interface to display only runs once, when the window is created.  One way to get what you need is to create all of the boxes up-front, and conditionally display them (shown below).  The alternative would be to dynamically create and destroy the boxes from the Radio Box callback function.

 

Names Default To Here( 1 );
SampleConfig = "2 x 2";
		
New Window( "Select Sample Configuration",
	<<Modal, //
	H List Box(
		Panel Box( "Select Sample Configuration",
			rb = Radio Box(
				{"2 x 2", "3 x 3"},
				<<setfunction(
					Function( {this},
						SampleConfig = rb << Get Selected;
						if3x3 << Set( SampleConfig == "3 x 3" );
						if2x2 << Set( SampleConfig == "2 x 2" );
						Print( "Selection Changed!" );
						Print( SampleConfig );
					)
				)
			)
		),
		pbox1 = Panel Box( "Scribe #s",
			if3x3 = If Box(
				0,
				H List Box(
					"Scribe #s", 

					col3_1 = Number Col Edit Box( , [1, 4, 7] ),
					col3_2 = Number Col Edit Box( , [2, 5, 8] ),
					col3_3 = Number Col Edit Box( , [3, 6, 9] )
				)
			),
			if2x2 = If Box(
				1,
				H List Box(
					"Scribe #s", 

					col2_1 = Number Col Edit Box( , [1, 3] ),
					col2_2 = Number Col Edit Box( , [2, 4] )
				), 

			)
		)
	)
);

View solution in original post

Re: How to live update a panel box?

Here is one example where the content is added and removed dynamically.  I also added an example of how to get the output from the modal dialog.  In the first example using IfBox, this could be done by using <<ReturnResult and the results would appear in the output variable w.  The <<ReturnResult method will not work with content that is added on the fly, so I added an <<OnClose expression to get the results from the dialog before it is dismissed.

 

Names Default To Here( 1 );

ui2x2 = Expr(
	H List Box(
		col_1 = Number Col Edit Box( , [1, 3] ),
		col_2 = Number Col Edit Box( , [2, 4] ),
	)
);

ui3x3 = Expr(
	H List Box(
		col_1 = Number Col Edit Box( , [1, 4, 7] ),
		col_2 = Number Col Edit Box( , [2, 5, 8] ),
		col_3 = Number Col Edit Box( , [3, 6, 9] )
	)
);

results = New Namespace();
results:SampleConfig = "2 x 2";
w = New Window( "Select Sample Configuration",
	<<Modal,
	<<On Close(
		results:col1 = col_1 << Get();
		results:col2 = col_2 << Get();
		if (results:SampleConfig == "3 x 3",
			results:col3 = col_3 << Get();
		)
	),
	H List Box(
		Panel Box( "Select Sample Configuration",
			rb = Radio Box(
				{"2 x 2", "3 x 3"},
				<<setfunction(
					Function( {this},
						results:SampleConfig = rb << Get Selected;
						(pbox1 << Child()) << Delete Box;
						If( results:SampleConfig == "2 x 2",
							pbox1 << Append( Eval( ui2x2 ) ),
							pbox1 << Append( Eval( ui3x3 ) )
						);
						Print( "Selection Changed!" );
						Print( results:SampleConfig );
					)
				)
			)
		),
		pbox1 = Panel Box( "Scribe #s", Eval( ui2x2 ) )
	)
);

if (w["Button"] == 1,
	results << Show Contents();,
	Print("Cancelled!");
);

View solution in original post

4 REPLIES 4

Re: How to live update a panel box?

Your If() statement to choose which interface to display only runs once, when the window is created.  One way to get what you need is to create all of the boxes up-front, and conditionally display them (shown below).  The alternative would be to dynamically create and destroy the boxes from the Radio Box callback function.

 

Names Default To Here( 1 );
SampleConfig = "2 x 2";
		
New Window( "Select Sample Configuration",
	<<Modal, //
	H List Box(
		Panel Box( "Select Sample Configuration",
			rb = Radio Box(
				{"2 x 2", "3 x 3"},
				<<setfunction(
					Function( {this},
						SampleConfig = rb << Get Selected;
						if3x3 << Set( SampleConfig == "3 x 3" );
						if2x2 << Set( SampleConfig == "2 x 2" );
						Print( "Selection Changed!" );
						Print( SampleConfig );
					)
				)
			)
		),
		pbox1 = Panel Box( "Scribe #s",
			if3x3 = If Box(
				0,
				H List Box(
					"Scribe #s", 

					col3_1 = Number Col Edit Box( , [1, 4, 7] ),
					col3_2 = Number Col Edit Box( , [2, 5, 8] ),
					col3_3 = Number Col Edit Box( , [3, 6, 9] )
				)
			),
			if2x2 = If Box(
				1,
				H List Box(
					"Scribe #s", 

					col2_1 = Number Col Edit Box( , [1, 3] ),
					col2_2 = Number Col Edit Box( , [2, 4] )
				), 

			)
		)
	)
);
dylan-1
Level I

Re: How to live update a panel box?

Thank you Dan! Is the only advantage of the second method if you didn't know from the start the different configurations that were possible (for example if you had the user input an n x m matrix), or are there other advantages/disadvantages? Is it too much to ask for an example of the second method as well?

 

Thanks for your help,

Dylan

Re: How to live update a panel box?

Here is one example where the content is added and removed dynamically.  I also added an example of how to get the output from the modal dialog.  In the first example using IfBox, this could be done by using <<ReturnResult and the results would appear in the output variable w.  The <<ReturnResult method will not work with content that is added on the fly, so I added an <<OnClose expression to get the results from the dialog before it is dismissed.

 

Names Default To Here( 1 );

ui2x2 = Expr(
	H List Box(
		col_1 = Number Col Edit Box( , [1, 3] ),
		col_2 = Number Col Edit Box( , [2, 4] ),
	)
);

ui3x3 = Expr(
	H List Box(
		col_1 = Number Col Edit Box( , [1, 4, 7] ),
		col_2 = Number Col Edit Box( , [2, 5, 8] ),
		col_3 = Number Col Edit Box( , [3, 6, 9] )
	)
);

results = New Namespace();
results:SampleConfig = "2 x 2";
w = New Window( "Select Sample Configuration",
	<<Modal,
	<<On Close(
		results:col1 = col_1 << Get();
		results:col2 = col_2 << Get();
		if (results:SampleConfig == "3 x 3",
			results:col3 = col_3 << Get();
		)
	),
	H List Box(
		Panel Box( "Select Sample Configuration",
			rb = Radio Box(
				{"2 x 2", "3 x 3"},
				<<setfunction(
					Function( {this},
						results:SampleConfig = rb << Get Selected;
						(pbox1 << Child()) << Delete Box;
						If( results:SampleConfig == "2 x 2",
							pbox1 << Append( Eval( ui2x2 ) ),
							pbox1 << Append( Eval( ui3x3 ) )
						);
						Print( "Selection Changed!" );
						Print( results:SampleConfig );
					)
				)
			)
		),
		pbox1 = Panel Box( "Scribe #s", Eval( ui2x2 ) )
	)
);

if (w["Button"] == 1,
	results << Show Contents();,
	Print("Cancelled!");
);
dylan-1
Level I

Re: How to live update a panel box?

Thank you Dan, that is very helpful!
Best,
Dylan