15
$\begingroup$

I have a GUI with a number of TabView and other Manipulate controls. Sometimes clicking from one tab view to the other can take a while, and I would like to have a global "Please wait" indicator.

So one way is to implement it for each button or slider, but I would essentially like to have a visual indicator that will show if any cell in my notebook is being evaluated.

Any ideas or suggestions? (Have searched for answers here but I only found those related to progress bars for a specific calculation)

$\endgroup$
  • $\begingroup$ what OS is your GUI running on? $\endgroup$ – rcollyer Sep 6 '12 at 20:29
  • $\begingroup$ Doesn't your notebook window change its title to Running... <filename>? Mine does and in addition, also shows a ring around the icon to indicate that it is evaluating something (might be mac only). $\endgroup$ – rm -rf Sep 6 '12 at 20:42
  • 1
    $\begingroup$ OS X, but it is for a Windows implementation. So yes, I know that the cells are evaluating - you can see it by the double cell bracket, but this is too subtle for the end users, and they need a clear graphical sign that something is happening, or they will keep on clicking on various buttons :-) $\endgroup$ – BlueMac Sep 6 '12 at 20:52
  • $\begingroup$ I can't play with it right now, but see if you can do something with $DynamicEvaluation. It returns True if inside a Dynamic and False otherwise. A DockedCell might be a good place to place an indicator $\endgroup$ – rm -rf Sep 6 '12 at 21:51
  • 1
    $\begingroup$ Why is there a delay? TabViews run everything at the beginning and always treat the dynamic content on all tabs as if visible. Is it just a delay because of front end rendering or you placed some dynamic code dependent on the current selected tab that has to run when it is changed? $\endgroup$ – Rojo Sep 7 '12 at 0:42
12
$\begingroup$

First, let's make a 'busy' animation

wait =
 DynamicModule[
    {i = 1, b = Import["http://ims.cartoninjas.net/manifoldtemplate/images/BusyAnimation.gif"]},
    Dynamic@Refresh[b[[i = Mod[i + 1, Length[b], 1]]], 
                    UpdateInterval -> .1, 
                    TrackedSymbols -> {}
    ]
 ]

enter image description here

Now, lets make a radio button bar to control the busy state in this demo:

Column[{"Waiting", RadioButtonBar[Dynamic[waiting], {True, False}]}]

Mathematica graphics

Finally, here's the TabView. I use Overlay to overlay the busy animation in the busy state and prevent selection of the TabView:

g = {"Beethoven", "CastleWall", "Cone", "Cow"};
Overlay[
  {
    TabView[(# -> ExampleData[{"Geometry3D", #}] &) /@ g], 
    Dynamic@If[waiting, wait, "", ""]
  }, 
  {1, 2}, 
  Dynamic[If[waiting, 0, 1, 1]], 
  Alignment -> Top
]

Mathematica graphics

It is the responsibility of your code to set and unset the busy state. Probably somewhere in the beginning and end, respectively, of a Dynamic piece of code in TabView.


Update As of Version 10.0.2 Animator can be used to create the busy animation. There are several kinds available, but one resembling the above can be generated using:

Animator[Appearance -> "Necklace"]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Any ideas on how to set this busy state ? What function can I use to tell if a notebook is currently evaluating or not? $\endgroup$ – lara Jul 24 '13 at 11:09
  • $\begingroup$ @LaraJordan Setting the busy state is simply a question of setting the waiting variable to either True or False. If you have a block of code that may be evaluating you could do that at the beginning and end of that block. In the example above I used ExampleData to stand for the code, but it could be a comple program. $\endgroup$ – Sjoerd C. de Vries Jul 24 '13 at 12:16
  • $\begingroup$ Sorry, I was bieng an idiot! Thanks. $\endgroup$ – lara Jul 25 '13 at 7:10
  • $\begingroup$ @SjoerdC.deVries, how about something practical and geared to the notebook structure: ie a set of icons (eg squares or circles) one for each cell in a notebook that progressively go from empty to filled as each cell expression is executed? $\endgroup$ – alancalvitti May 10 '17 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.