Re: Dialog.create not working when using toolbar
Posted by
Rasband, Wayne (NIH/NIMH) [E] on
Jan 11, 2011; 2:58am
URL: http://imagej.273.s1.nabble.com/Dialog-create-not-working-when-using-toolbar-tp3686021p3686022.html
On Jan 10, 2011, at 7:27 PM, tankhead wrote:
> Hey guys,
>
> I should first mention that my macro works perfect if I simply run the macro
> from the dropdown bar or from edit. Currently, I have the following macro
> assigned to the toolbar by adding the following code into the file
> "StartupMacros.txt"
>
> macro "WLT Action Tool- A bunch of code here for the icon" {
> run("Run...", "run=[*C:\\Documents and
> Settings\\USERNAMEHERE\\Desktop\\FILENAMEHERE.txt*]");
> }
>
> The problem I am running into is that the first section of my code which
> includes dialog boxes does not make them pop-up, basically...no dialog box
> shows pops up for the user, it seemed to skip straight to the getDirectory
> code. I tested my program by inserting commands, such as, print("skipped
> here1");...print("skipped here2"), at the top of the program and after each
> dialog box. All of them printed, verifying that indeed the program was not
> completely skipping the code prior to the getDirectory command. I dont know
> how to change this so the dialog boxes work properly and appear to take in
> the user's choices.
>
>
> Here is the first part of my code where the problem exists:
>
> t=newArray("Yes","No");
> Dialog.create("Run Automated Winston Lutz Test");
> Dialog.addChoice("Run Winston Lutz Test?",t);
> Dialog.show();
> choice3=Dialog.getChoice();
>
> if(choice3=="No")
> {
> exit();
> }
>
>
> eval("js", "IJ.getInstance().setLocation(5000, 5000)");
> setBatchMode(true);
>
> tab=newArray("Input all images from folder","Input individual images from
> folder");
> Dialog.create("ImageJ Automated Winston-Lutz");
> Dialog.addChoice("Please Select at One of the Following:",tab);
> Dialog.show();
> choice=Dialog.getChoice();
>
> swidth = screenWidth;
> sheight = screenHeight;
> swf = (swidth/2)-150;
> shf = (sheight/2)-100;
>
>
> if (choice=="Input all images from folder")
> {
> dir=getDirectory("Choose a Source Directory "); <====Seems to ignore ALL
> previous code and
> list = getFileList(dir);
> SKIPS TO HERE
>
> Dialog.create("Specify File extension");
> Dialog.addString("File extension","jpg",3);
> Dialog.show();
>
>
> What seems to be happening?
> Thanks for the help.
>
> -Dan
Try changing the code you added to StartupMacros.txt to
macro "WLT Action Tool- A bunch of code here for the icon" {
runMacro(file-path);
}