Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the File Chooser Widget to open an image #87

Open
DFKSingleton opened this issue Apr 4, 2020 · 2 comments
Open

Using the File Chooser Widget to open an image #87

DFKSingleton opened this issue Apr 4, 2020 · 2 comments
Labels

Comments

@DFKSingleton
Copy link

DFKSingleton commented Apr 4, 2020

I wanted to use the File Chooser Widget to open one of several image (PNG) files for further analysis with nip2. The "obvious" approach of using the output from the File Chooser widget to open a file did not seem to work. After spending some time examining the nip2 code, I was able to get a working system, which I am documenting here because it may be of use to others. The first thing to note is that the file chooser widget returns an object by calling the function Pathname (see below)

/* An editable filename.
 */
Pathname caption value = class 
	_Object {
	_check_args = [
		[caption, "caption", check_string],
		[value, "value", check_string]
	];
}

It is therefore necessary to extract the 'value' member of this object. To do this, I wrote a small nip2 toolkit extension, as follows:

// Load an Image File
loadFile fn
 =  Image_file fn.value;

In the toolkit editor, it looks as follows:
grafik

I was then able to connect the two together, using the standard nip2 graphical editor:
grafik

After this step, I could choose the file I wanted to load and then process it further. I hope that this helps others.

One small comment about the nip2 documentation. The section §6.13, which should document the _Object class is empty!

@jcupitt
Copy link
Member

jcupitt commented Apr 4, 2020

Yes, that works, or of course you could enter Image_file A32.value in A36.

I think when I wrote the docs the toolkits were still in flux, so I didn't want to spend a lot of time documenting them. Perhaps for nip3 :)

@jcupitt jcupitt added the tip label Apr 4, 2020
@DFKSingleton
Copy link
Author

Yes, of course - silly me - your suggestion is much better. I unfortunately did not think of it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants