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
ms
Super User (Alumni) ms
Super User (Alumni)

JSL: Restore PanelBox size in dynamic display box

Panel Box() objects automatically adapt their size as the content expands. However the reverse seems not to be true. Pressing the right radio button In the example script below stretches the window as the checkbox descriptors expand. Reselecting the left radio button results in shorter descriptors but the panel box (and window) retains its expanded state.

How can I force the panel box to revert to it's orginal size? Or is there another display box type that is "smarter" in this respect?

I have tried to save the original size in a variable (using pb1 << Get Size) and apply that when radio button 1 is reselected, but Panel Box() seems not to recognize a Set Size() message.

str =

{"case 1: low dose  really long description really long description really long description",

"case 2: high dose  really long description really long description really long description"

};

short_str = Eval List( {Left( str[1], 6 ), Left( str[2], 6 )} );

pb1=expr(Panel Box( ,

          hlb1 = V List Box(tb = Text Box( "Select Case" ),

                    cb = Check Box( short_str ),

                    vlb1 = V List Box(

  Spacer Box(),

  H List Box(

                                        rb2 = Radio Box(

  "Show name",

                                                  cb << delete;

                                                  vlb1 << prepend( cb = Check Box( short_str ))),

                                        rb1 = Radio Box(

  "Show description",

                                                  cb << delete;

                                                  vlb1 << prepend( cb = Check Box( str )))))))

);

pb2 = Expr(

  Panel Box( ,

  V List Box(

  Button Box( "Run" ),

                              Button Box( "Cancel", << close window ),

  Spacer Box()

)));

New Window( "Example",

          hlb = H List Box(pb1,pb2)

);

rb2 << group( rb1 );

2 REPLIES 2
David_Burnham
Super User (Alumni)

Re: JSL: Restore PanelBox size in dynamic display box

I don't think the problem is with the panel box specifically - you get the same problem is you remove the panel box.

It's the window itself that increases its size to accomodate the content. 

The solution you propose therefore works if you apply the resizing to the window.  However, once a window is resized it wont resize itself so you need to control the resize to make it larger as well as smaller. 

This code seems to work ...

str = {"case 1: low dose  really long description really long description really long description",

"case 2: high dose  really long description really long description really long description"};

short_str = Eval List( {Left( str[1], 6 ), Left( str[2], 6 )} );

ss_small = {};

ss_large = {};

pb1 = Expr(

  Border Box( ,

                    hlb1 = V List Box(

                              tb = Text Box( "Select Case" ),

                              cb = Check Box( short_str ),

                              vlb1 = V List Box(

                                        Spacer Box(),

                                        H List Box(

                                                  rb2 = Radio Box(

                                                            "Show name",

                                                            cb << delete;

                                                            vlb1 << prepend(

                                                                      cb = Check Box(

                                                                                short_str

                                                                      )

                                                            );

                                                            nw << set window size(ss_small[1],ss_small[2])

                                                  ),

                                                  rb1 = Radio Box(

                                                            "Show description",

                                                            cb << delete;

                                                            vlb1 << prepend( cb = Check Box( str ) );

                                                            If (NItems(ss_large)==0,

                                                                      ss_large = nw << get window size

                                                            ,

                                                                      nw << set window size(ss_large[1],ss_large[2])

                                                            )

                                                  )

                                        )

                              )

                    )

          )

);

pb2 = Expr( Panel Box( , V List Box( Button Box( "Run" ), Button Box( "Cancel", <<close window ), Spacer Box() ) ) );

nw = New Window( "Example", hlb = H List Box( pb1, pb2 ) );

rb2 << group( rb1 );

ss_small = nw <<get window size;

Dave

-Dave
ms
Super User (Alumni) ms
Super User (Alumni)

JSL: Restore PanelBox size in dynamic display box

Thanks Dave! It works. I explored a similar solution using set content size() instead of set window size(). The commands seem to be interchangeble, at least in this example.

There is still one little quirk. When toggling between the two radio buttons the window setting fails every second or third time. The window then becomes smaller than its content. This problem arises in both your and mine solutions. I think it results form some asynchrony in code execution, e.g. that window size is fetched before the prepend() is completed. However inserting Wait(0.01) in the rb1 button script seems to eliminate the peculiar behaviour. See excerpt below.

Maybe this is machine specific so the oddity may not happen for everyone. I run JMP 9.02 on a pretty fast Mac Pro.

...If (NItems(ss_large)==0, Wait(0.01);

           ss_large = nw << get window size

   ,

           nw << set window size(ss_large[1],ss_large[2])

)...

Thanks again!