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
lukasz
Level IV

How to open an image file after clicking on Picture Box?

Hello Everybody,

I am using picture boxes to display 4 images loaded from files. The size of images needs to be reduced for displaying purposes. However, I would like to open an original image file after clicking on the image displayed in the picture box. I would appreciate for hints how to do that.

Best regards.

//initially no images
img1 = empty();
img2 = empty();
img3 = empty();
img4 = empty();
New Window("Images",             
		H List Box(
		Panel Box("El 1",  //place for EL images
			EL1 = Picture Box(img1),				
		),
		Panel Box("El 2",
			EL2 = Picture Box(img2),
		),
		Panel Box("El 3",
			EL3 = Picture Box(img3),
		),
		Panel Box("El 4",
			EL4 = Picture Box(img4),
		),
);
//here images will be opened
//img1 = open("D:\image.tif", tif);
//img1 << set size({image_w_new, image_h_new});
//EL1 << set image (img1);
1 ACCEPTED SOLUTION

Accepted Solutions
vince_faller
Super User (Alumni)

Re: How to open an image file after clicking on Picture Box?

Could use a mousebox.  But understand that the mousebox will make you lose other mouse functionality for that object (context menus, selecting graphs, etc)

 

Names default to here(1);
//initially no images
img1 = empty();
img2 = empty();
img3 = empty();
img4 = empty();

New Window("Images",             
	H List Box(
		mb = MouseBox(
			Panel Box("El 1",  //place for EL images
				EL1 = Picture Box(img1),				
			),
			<<setTrackEnable( 1 ),
			<<setTrack(
				Function( {this, clickpt},
					this << setCursor( "Finger" ) /* button-up tracking - use the hand */
				)
			),
			<< Set Click Enable(1), 
			<<Set Click(
				Function( {this, clickpt, event}, /*Is Alt Key(),Is Control Key(),Is Shift Key() should be captured on "Pressed" */
					{DEFAULT LOCAL},
					If( event == "Released" | event == "Canceled",
						this << setCursor( "Hand" ) /* switch back to hand immediately */
					,
						this << setCursor( "Finger" ) /* change cursor during drawing */
					);
					If( event == "Pressed",
						img = new image("$SAMPLE_DATA\..\images\Pi.gif");
						img << Set Size({50, 50});
						
						// EL1 << Set image(img);
						// if you're making a bunch of these you could find the picture box
						// instead of having a direct reference to it
						// this currently is dependent on the tree structure
						pb  = (this << Child()) << Child();
						pb << Set image(img);
					);
				)
			)
		),
		Panel Box("El 2",
			EL2 = Picture Box(img2),
		),
		Panel Box("El 3",
			EL3 = Picture Box(img3),
		),
		Panel Box("El 4",
			EL4 = Picture Box(img4),
		),
	)
);
Vince Faller - Predictum

View solution in original post

2 REPLIES 2
vince_faller
Super User (Alumni)

Re: How to open an image file after clicking on Picture Box?

Could use a mousebox.  But understand that the mousebox will make you lose other mouse functionality for that object (context menus, selecting graphs, etc)

 

Names default to here(1);
//initially no images
img1 = empty();
img2 = empty();
img3 = empty();
img4 = empty();

New Window("Images",             
	H List Box(
		mb = MouseBox(
			Panel Box("El 1",  //place for EL images
				EL1 = Picture Box(img1),				
			),
			<<setTrackEnable( 1 ),
			<<setTrack(
				Function( {this, clickpt},
					this << setCursor( "Finger" ) /* button-up tracking - use the hand */
				)
			),
			<< Set Click Enable(1), 
			<<Set Click(
				Function( {this, clickpt, event}, /*Is Alt Key(),Is Control Key(),Is Shift Key() should be captured on "Pressed" */
					{DEFAULT LOCAL},
					If( event == "Released" | event == "Canceled",
						this << setCursor( "Hand" ) /* switch back to hand immediately */
					,
						this << setCursor( "Finger" ) /* change cursor during drawing */
					);
					If( event == "Pressed",
						img = new image("$SAMPLE_DATA\..\images\Pi.gif");
						img << Set Size({50, 50});
						
						// EL1 << Set image(img);
						// if you're making a bunch of these you could find the picture box
						// instead of having a direct reference to it
						// this currently is dependent on the tree structure
						pb  = (this << Child()) << Child();
						pb << Set image(img);
					);
				)
			)
		),
		Panel Box("El 2",
			EL2 = Picture Box(img2),
		),
		Panel Box("El 3",
			EL3 = Picture Box(img3),
		),
		Panel Box("El 4",
			EL4 = Picture Box(img4),
		),
	)
);
Vince Faller - Predictum
lukasz
Level IV

Re: How to open an image file after clicking on Picture Box?

Thank you for suggestions and code! With opening of an original image I meant opening the file for example in Paint in order examine details of image in original size. Is there way to do that? Regards

EDIT:

Actually I could create a new window and then open the image again but in original size.

EDIT:

Ok, I managed to open the new window and display the image (using Paint or something another is actually not necessary). I am providing code from vince_faller with very small changes, maybe it will be helpful for somebody. Thank you once again.

Names default to here(1);
//initially no images
img1 = empty();
img2 = empty();
img3 = empty();
img4 = empty();

New Window("Example",             
    V List Box(
		H List Box(
		mb = MouseBox(
			Panel Box("El 1",  //place for EL images
				EL1 = Picture Box(img1),				
			),
			<<setTrackEnable( 1 ),
			<<setTrack(
				Function( {this, clickpt},
					this << setCursor( "Finger" ) /* button-up tracking - use the hand */
				)
			),
			<< Set Click Enable(1), 
			<< Set Click(
				Function( {this, clickpt, event}, /*Is Alt Key(),Is Control Key(),Is Shift Key() should be captured on "Pressed" */
					{DEFAULT LOCAL},
					If( event == "Released" | event == "Canceled",
						this << setCursor( "Hand" ) /* switch back to hand immediately */
					,
						this << setCursor( "Finger" ) /* change cursor during drawing */
					);
					If( event == "Pressed",					
						New Window("Image",
							img_big = new image("$SAMPLE_DATA\..\images\Pi.gif");
							//img_big << Set Size({50, 50});
							Picture Box(img_big);
							// if you're making a bunch of these you could find the picture box
							// instead of having a direct reference to it
							// this currently is dependent on the tree structure
							//pb  = (this << Child()) << Child();
							//pb << Set image(img);
						);
					);
				)
			)
		),
		Panel Box("El 2",
			EL2 = Picture Box(img2),
		),
		Panel Box("El 3",
			EL3 = Picture Box(img3),
		),
		Panel Box("El 4",
			EL4 = Picture Box(img4),
		),
	),
);