Closed jimmyDunne closed 6 years ago
Perhaps utils.FileUtils.getInstance().browseForFolder(0, "blah blah")
?
https://msdn.microsoft.com/en-us/library/windows/desktop/bb774065(v=vs.85).aspx
Thanks, Tom. Still something funky going on.
resultsFolderCMC = utils.FileUtils.getInstance().browseForFolder("Select the folder with CMC Results",0);
opens a dialogue, but when a folder is selected an exception is returned;
at org.opensim.utils.FileUtils.browseForFolder(FileUtils.java:286)
at org.opensim.utils.FileUtils.browseForFolder(FileUtils.java:253)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
java.lang.NullPointerException: java.lang.NullPointerException
I am doing this on a Mac. This seems to be an issue with the custom functions here. @aymanhab, please let me know what the call should be or if it requires a fix on the GUI side. Thanks.
resultsFolderCMC = utils.FileUtils.getInstance().browseForFolder("Select the folder with CMC Results",0); opens a dialogue, but when a folder is selected an exception is returned;
I recommended passing 0 as the first argument, not the second. Regardless, I was just guessing; Ayman will know.
@jimmyDunne the code suggests all these signatures are supported `` public String browseForFolder()
public String browseForFolder(String description, boolean allowCreate)
public String browseForFolder(Frame parent, String description, boolean allowCreate)
`` Can you provide a full snippet as I don't know what classes/packages are imported in your environment. And does the same code work on Windows? Thanks
import org.opensim.utils as utils
# Obtain Directory containing CMC results
resultsFolderCMC = utils.FileUtils.getInstance().browseForFolder("Select the folder with CMC Results",0);
The code is in the GUI repo here. You will be able to test it pretty easily.
Same code ran on Windows without issue, will try on an osx machine with debugger.
On iMacPro works like a charm, and brings a dialog to browse for folder. anything specific to your environment @jimmyDunne ? Anybody else to try the two lines above?
@jimmyDunne Can I close this issue now?
browseForFolder() is still not working in the GUI on Mac.
trcDataFolder = utils.FileUtils.getInstance().browseForFolder("Select the folder")
returns
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: browseForFolder(): expected 0 or 2-3 args; got 1
trcDataFolder = utils.FileUtils.getInstance().browseForFolder("Select the folder",0);
Opens a dialogue but once you select a folder it returns
>>> trcDataFolder = utils.FileUtils.getInstance().browseForFolder("Select the folder",0);
Traceback (most recent call last):
File "<input>", line 1, in <module>
at org.opensim.utils.FileUtils.browseForFolder(FileUtils.java:286)
at org.opensim.utils.FileUtils.browseForFolder(FileUtils.java:253)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
java.lang.NullPointerException: java.lang.NullPointerException
trcDataFolder = utils.FileUtils.getInstance().browseForFolder();
Opens a dialogue but once you select a folder it returns
>>> trcDataFolder = utils.FileUtils.getInstance().browseForFolder();
Traceback (most recent call last):
File "<input>", line 1, in <module>
at org.opensim.utils.FileUtils.browseForFolder(FileUtils.java:286)
at org.opensim.utils.FileUtils.browseForFolder(FileUtils.java:248)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
java.lang.NullPointerException: java.lang.NullPointerException
Jen: Scripts in the GUI commonly ask users to browse for a folder. Need an example on Mac +Windows of how to do this.
Use code in GUI script:
resultsFolderCMC = utils.FileUtils.getInstance().browseForFolder("Select the folder with CMC Results")
Returns an exception;
I suppose the method has changed. how is the new version written?