User interface to select multiple files and folders
sjr51
I have a long procedure which starts with the User needing to pick the 4 different types of file from disk and specify a disk folder for the outputs. Everything runs at the moment but the User has to know which files to pick and in what order. I'd like a better solution, if anyone has some ideas or perhaps some code to point me to, that would be great!
My ideas so far:
1. A prompt at the start that the User must dismiss telling them which order to pick everything - don't know how to do that and is not very robust
2. A message on each dialog. I've tried this for specifying the output folder (don't know if possible for picking other files) but under macOS it seems that the /M flag does not get displayed(?)
3. A proper solution. Perhaps a panel where the user can pick files and also change their mind if they pick the wrong thing.
Any help would be appreciated.
The first function is below (the subfunction runs
LoadWave
twice).Function LoadImagesForAnalysis()
// Load channel 1 tiff
ImageLoad/T=tiff/N=ch1tiff/O/S=0/C=-1 ""
// Load channel 2 tiff
ImageLoad/T=tiff/N=ch2tiff/O/S=0/C=-1 ""
// Now load the ComDet data
Load2ChComDetResults()
// Now specify the OutputFolder
NewPath/O/Q/M="Please find disk folder" OutputFolder
if (V_flag!=0)
DoAlert 0, "Disk folder error"
Return -1
endif
PathInfo/S OutputFolder
String/G gOutputFolder = S_path
End
// Load channel 1 tiff
ImageLoad/T=tiff/N=ch1tiff/O/S=0/C=-1 ""
// Load channel 2 tiff
ImageLoad/T=tiff/N=ch2tiff/O/S=0/C=-1 ""
// Now load the ComDet data
Load2ChComDetResults()
// Now specify the OutputFolder
NewPath/O/Q/M="Please find disk folder" OutputFolder
if (V_flag!=0)
DoAlert 0, "Disk folder error"
Return -1
endif
PathInfo/S OutputFolder
String/G gOutputFolder = S_path
End
// make global text wave to store paths and output folder
if (!WaveExists(root:Packages:myFolder:Path))
NewDataFolder/O root:Packages
NewDataFolder/O root:Packages:myFolder
Make/T/O/N=3 root:Packages:myFolder:Path
wave/T Path = root:Packages:myFolder:Path
endif
NewPanel /W=(81,73,774,248)
Button SelectFile1,pos={12.00,10.00},size={140.00,20.00},proc=ButtonProc,title="Select File No. 1"
Button SelectFile2,pos={12.00,41.00},size={140.00,20.00},proc=ButtonProc,title="Select File No. 2"
Button Output,pos={13.00,72.00},size={140.00,20.00},proc=ButtonProc,title="Select Output Folder"
SetVariable File1,pos={168.00,13.00},size={500.00,14.00},value= Path[0]
SetVariable File2,pos={168.00,43.00},size={500.00,14.00},value= Path[1]
SetVariable File5,pos={168.00,75.00},size={500.00,14.00},value= Path[2]
Button DoIt,pos={291.00,121.00},size={100.00,20.00},proc=ButtonProc,title="Do It"
end
// define buttons
Function ButtonProc(ctrlName) : ButtonControl
String ctrlName
wave/T Path = root:Packages:myFolder:Path
variable refnum
strswitch(ctrlName)
case "SelectFile1" :
// get File Paths
Open/D/R/F="*.tif"/M="Select fist file" refNum
if (strlen(S_FileName) == 0) // user cancelled or some error occured
return -1
endif
Path[0] = S_fileName
break
case "SelectFile2" :
// get File Paths
Open/D/R/F="*.tif"/M="Select fist file" refNum
if (strlen(S_FileName) == 0)
return -1
endif
Path[1] = S_fileName
break
case "Output" :
// set outputfolder
NewPath/Q/O OutputPath
PathInfo OutputPath
Path[2] = S_Path
break
case "DoIt" :
// run your loadwave commands and other functions
DoStuff(path)
break
EndSwitch
End
// run your stuff
function DoStuff(path)
wave/T path
print "LoadWave from: " + Path[0]
print "LoadWave from: " + Path[1]
print "Calculate output and save to: " + Path[2]
end
January 20, 2017 at 05:08 am - Permalink
January 20, 2017 at 07:02 am - Permalink
January 20, 2017 at 08:37 am - Permalink
January 20, 2017 at 09:36 am - Permalink