Hi,
I've written myself a little image viewer to enable me to browse a folder of digital photographs from within JMP 9, and include the script below. The problem I have is that I want to retain the relative positions of the List Box and the Graph Box in which the images are being shown while the tool is being used. At the moment, when I select an image from the list to replace the initial one, the new Graph Box is appended underneath the list, whereas I want it to appear in the same position that I originally put it - to the right of the list. I know why it's doing it: the "<< append" property attaches the new chart vertically. The question is, how can I modify the script to append it horizontally?
// Start of program;
Clear Log();
PhotoFolder = "C:\My Photos\Camera Card 1\102_FUJI\";
ImageList = Files In Directory( PhotoFolder ); // Every file is a JPEG, so no need to filter them;
Expr_Create_Image = Expr(
ImageName = PhotoFolder || ImageList[ImageNumber];
gb = Graph Box(
Frame Size( 410, 308 ),
X Scale( 0, 100 ),
Y Scale( 0, 100 ),
<<background color( {0.7, 0.7, 0.7} ),
<<Add Image( Open( ImageName ), Bounds( Left( 5 ), Right( 95 ), Top( 95 ), Bottom( 5 ) ) )
);
// I don't want to see the axes, so get rid of them;
gb[axisbox( 2 )] << delete;
gb[axisbox( 1 )] << delete;
);
Expr_Replace_Chart = Expr(
nw[OwnerBox( 1 )] << delete; // Delete the old one from the window;
nw << append( gb ); // Append the new one;
);
lb = List Box(
ImageList,
ImageNumber = (lb << get selected indices)[1];
Eval( Expr_Create_Image ); // Create a new graph box;
Eval( Expr_Replace_Chart ); // Substitute the new graph for the old one;
,
max selected( 1 )
);
ImageNumber = 1; // Initially show the first one;
Eval( Expr_Create_Image ); // Create the chart;
lb << set selected( ImageNumber, 1 ); // Pre-select the first element of the list;
nw = New Window( "New Window", H List Box( lb, gb ) ); // And display the window;
// End of program;
More generally, is there a way simply to replace the original chart with the new one in such a way that it isn't necessary to partially deconstruct and then reconstruct the display window, the way I'm doing it at the moment? The obvious solution would be simply to replace the initial image within the Graph Box with the new one selected from the List Box, but I can't seem to do that: using the "<< add image" property on the same Graph Box a second time doesn't seem to work – which is why at the moment I’m creating a new Graph Box every time.
Many thanks for any suggestions.