From: Nate Dudenhoeffer on
I would like to have a custom dialog appear while an evaluation is in
progress (maybe even add that familiar spinning flower). I know it is easy
for an experienced user to see when Mathematica is working, but this would
help novice users who use some of my notebooks.

Does anyone have suggestions on how to do this? I can use CreateDialog, but
how do I close the dialog when the evaluation is done? DialogReturn only
seems to work if it is contained in the dialog, and if the entire evaluation
is contained in the CreateDialog, then the dialog doesn't appear until the
evaluation is complete.

Any suggestions would be appreciated.

Thanks,
Nate


From: Nate Dudenhoeffer on
I answered my own question. The key was using NotebookClose, not
DialogReturn[].

And, since I have far too much time on my hands, here is some code to create
a dynamic flower that should look familiar to Mac users. Along with an
example of how to use it:

myflower := Module[{w, bigD, d},
w = .22;
bigD = 2;
d = 1;
Dynamic[
Graphics[{
Rotate[
Table[
{GrayLevel[Min[{1 - (i/(2*\[Pi])), .8}]],
Disk[{bigD*Sin[i], bigD*Cos[i]}, w],
Polygon[{
{d*Sin[i] - w*Cos[i], d*Cos[i] + w*Sin[i]},
{bigD*Sin[i] - w*Cos[i], bigD*Cos[i] + w*Sin[i]},
{bigD*Sin[i] + w*Cos[i], bigD*Cos[i] - w*Sin[i]},
{d*Sin[i] + w*Cos[i], d*Cos[i] - w*Sin[i]}
}]
},
{i, 0, 2 \[Pi], 2 \[Pi]/12}
], -Clock[{2*\[Pi]/12, 2*\[Pi], 2*\[Pi]/11}, 2]],
White, Disk[{0, 0}, d*1.1]},
ImageSize -> {250, 250}
]
]
];

mydialog = CreateDialog[myflower,
Modal -> True,
WindowTitle -> "Working...",
WindowSize -> All,
WindowMargins -> Automatic,
Background -> White];
nd = 1;
While[nd < 10,
Pause[1];
nd++
]
NotebookClose[mydialog];

I hope someone else finds this useful too.

Nate

On Tue, Aug 10, 2010 at 2:55 AM, Nate Dudenhoeffer <dudenhoeffer(a)wisc.edu>wrote:

> I would like to have a custom dialog appear while an evaluation is in
> progress (maybe even add that familiar spinning flower). I know it is easy
> for an experienced user to see when Mathematica is working, but this would
> help novice users who use some of my notebooks.
>
> Does anyone have suggestions on how to do this? I can use CreateDialog,
> but
> how do I close the dialog when the evaluation is done? DialogReturn only
> seems to work if it is contained in the dialog, and if the entire
> evaluation
> is contained in the CreateDialog, then the dialog doesn't appear until the
> evaluation is complete.
>
> Any suggestions would be appreciated.
>
> Thanks,
> Nate
>
>
>

From: Albert Retey on
Hi,

> I would like to have a custom dialog appear while an evaluation is in
> progress (maybe even add that familiar spinning flower). I know it is easy
> for an experienced user to see when Mathematica is working, but this would
> help novice users who use some of my notebooks.
>
> Does anyone have suggestions on how to do this? I can use CreateDialog, but
> how do I close the dialog when the evaluation is done? DialogReturn only
> seems to work if it is contained in the dialog, and if the entire evaluation
> is contained in the CreateDialog, then the dialog doesn't appear until the
> evaluation is complete.
>
> Any suggestions would be appreciated.

Something like this?

Button["Start Calculation",
Module[{nb},
nb = CreateDialog[
Column[{"calculating ...",
ProgressIndicator[Dynamic[Clock[Infinity]], Indeterminate]}]];
Pause[3];(*here goes the lengthy calculation*)NotebookClose[nb]];,
Method -> "Queued"]

hth,

albert

From: Albert Retey on
Am 11.08.2010 10:47, schrieb Nate Dudenhoeffer:
> I answered my own question. The key was using NotebookClose, not
> DialogReturn[].
>
> And, since I have far too much time on my hands, here is some code to create
> a dynamic flower that should look familiar to Mac users. Along with an
> example of how to use it:
>
> myflower := Module[{w, bigD, d},
> w = .22;
> bigD = 2;
> d = 1;
> Dynamic[
> Graphics[{
> Rotate[
> Table[
> {GrayLevel[Min[{1 - (i/(2*\[Pi])), .8}]],
> Disk[{bigD*Sin[i], bigD*Cos[i]}, w],
> Polygon[{
> {d*Sin[i] - w*Cos[i], d*Cos[i] + w*Sin[i]},
> {bigD*Sin[i] - w*Cos[i], bigD*Cos[i] + w*Sin[i]},
> {bigD*Sin[i] + w*Cos[i], bigD*Cos[i] - w*Sin[i]},
> {d*Sin[i] + w*Cos[i], d*Cos[i] - w*Sin[i]}
> }]
> },
> {i, 0, 2 \[Pi], 2 \[Pi]/12}
> ], -Clock[{2*\[Pi]/12, 2*\[Pi], 2*\[Pi]/11}, 2]],
> White, Disk[{0, 0}, d*1.1]},
> ImageSize -> {250, 250}
> ]
> ]
> ];
>
> mydialog = CreateDialog[myflower,
> Modal -> True,
> WindowTitle -> "Working...",
> WindowSize -> All,
> WindowMargins -> Automatic,
> Background -> White];
> nd = 1;
> While[nd < 10,
> Pause[1];
> nd++
> ]
> NotebookClose[mydialog];
>
> I hope someone else finds this useful too.

looks like you are a person who would appreciate these small visual
enhancements:

mydialog = CreateDialog[
myflower,
Modal -> True,
WindowSize -> All,
WindowMargins -> Automatic,
WindowFrame -> "Frameless",
WindowOpacity -> 0.75,
WindowFloating -> True
]

I think WindowOpacity will not work for all OS.

For me the code you posted didn't work right away, and I think this is
because the Module doesn't behave as you wanted. It think when stuffing
constants into a Dynamic the use of With is usually the better choice:

With[{
w = 0.22,
bigD = 2,
d = 1
},
Dynamic[...]
]

hth,

albert

From: Nate Dudenhoeffer on
Thanks for the tips Albert.

Needless to say, I didn't test the final before I posted it. I forgot
module variables don't work in dialogs.

Nate


On Thu, Aug 12, 2010 at 4:31 AM, Albert Retey <awnl(a)gmx-topmail.de> wrote:

> Am 11.08.2010 10:47, schrieb Nate Dudenhoeffer:
> > I answered my own question. The key was using NotebookClose, not
> > DialogReturn[].
> >
> > And, since I have far too much time on my hands, here is some code to
> create
> > a dynamic flower that should look familiar to Mac users. Along with an
> > example of how to use it:
> >
> > myflower := Module[{w, bigD, d},
> > w = .22;
> > bigD = 2;
> > d = 1;
> > Dynamic[
> > Graphics[{
> > Rotate[
> > Table[
> > {GrayLevel[Min[{1 - (i/(2*\[Pi])), .8}]],
> > Disk[{bigD*Sin[i], bigD*Cos[i]}, w],
> > Polygon[{
> > {d*Sin[i] - w*Cos[i], d*Cos[i] + w*Sin[i]},
> > {bigD*Sin[i] - w*Cos[i], bigD*Cos[i] + w*Sin[i]},
> > {bigD*Sin[i] + w*Cos[i], bigD*Cos[i] - w*Sin[i]},
> > {d*Sin[i] + w*Cos[i], d*Cos[i] - w*Sin[i]}
> > }]
> > },
> > {i, 0, 2 \[Pi], 2 \[Pi]/12}
> > ], -Clock[{2*\[Pi]/12, 2*\[Pi], 2*\[Pi]/11}, 2]],
> > White, Disk[{0, 0}, d*1.1]},
> > ImageSize -> {250, 250}
> > ]
> > ]
> > ];
> >
> > mydialog = CreateDialog[myflower,
> > Modal -> True,
> > WindowTitle -> "Working...",
> > WindowSize -> All,
> > WindowMargins -> Automatic,
> > Background -> White];
> > nd = 1;
> > While[nd < 10,
> > Pause[1];
> > nd++
> > ]
> > NotebookClose[mydialog];
> >
> > I hope someone else finds this useful too.
>
> looks like you are a person who would appreciate these small visual
> enhancements:
>
> mydialog = CreateDialog[
> myflower,
> Modal -> True,
> WindowSize -> All,
> WindowMargins -> Automatic,
> WindowFrame -> "Frameless",
> WindowOpacity -> 0.75,
> WindowFloating -> True
> ]
>
> I think WindowOpacity will not work for all OS.
>
> For me the code you posted didn't work right away, and I think this is
> because the Module doesn't behave as you wanted. It think when stuffing
> constants into a Dynamic the use of With is usually the better choice:
>
> With[{
> w = 0.22,
> bigD = 2,
> d = 1
> },
> Dynamic[...]
> ]
>
> hth,
>
> albert
>
>