Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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)

share|improve this question
    
what OS is your GUI running on? –  rcollyer Sep 6 '12 at 20:29
    
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). –  rm -rf Sep 6 '12 at 20:42
1  
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 :-) –  BlueMac Sep 6 '12 at 20:52
    
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 –  rm -rf Sep 6 '12 at 21:51
1  
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? –  Rojo Sep 7 '12 at 0:42
add comment

1 Answer

up vote 9 down vote accepted

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.

share|improve this answer
    
Any ideas on how to set this busy state ? What function can I use to tell if a notebook is currently evaluating or not? –  Lara Jordan Jul 24 '13 at 11:09
    
@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. –  Sjoerd C. de Vries Jul 24 '13 at 12:16
    
Sorry, I was bieng an idiot! Thanks. –  Lara Jordan Jul 25 '13 at 7:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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