1
$\begingroup$

I'm making a words remembering program with Mathematica. I almost finished it but I need to implement a dynamics to make it more beautiful.

Try the following code:

Clear["`*"]
mode = True;
p[text_] := 
Pane[Style[text, 80, Bold, FontFamily -> "Calibri"], 
ImageSize -> {500, 270}, Alignment -> Center, Appearance -> None, 
FrameMargins -> None],Dynamic[If[mode,
Button[Dynamic@
DynamicModule[{}, t = Clock[1, 10, 1]; 
 If[t == 1 || Not@mode, mode = False; p["CONTEXT"],
Graphics[{Opacity@.3, Darker@Green, Rectangle[{0, 0}, {t, 1}]}, 
   PlotRange -> {{0, 1}, {0, 1}}, ImageSize -> {500, 270}, 
   AspectRatio -> (27/50)]]], mode = False, 
Enabled -> Dynamic@mode, ImageSize -> {500, 270}], 
Button[p["Press Again"], mode = True]]]

As you can see, when you press the button or let the progression bar reach its end, it will show the word "Press Again". If you click it again, it will back to the progression bar, however, the progress will be saved and continued. I would like to reset it everytime when it goes back to the progression page but I failed after tens of trails changing the position of Dynamic and other things.

So, my question is how to solve this problem and reset the progression bar everytime it goes back to this page?

Thanks very much!


BTW: I think I will post a link to my program when I've finished~ :) I consider it as quite a good one

$\endgroup$
  • $\begingroup$ related:78014 $\endgroup$ – Kuba Jun 16 '16 at 6:28
  • $\begingroup$ Er, sorry @Kuba I cannot find much similarities between these two questions as this question is more about how to tune Dynamic so that the number will reset itself everytime and in this question, the indicator interface could be called out multiple times. However, your related question is more about run it once and able to cancel its running process and change the interface to another one. Is my interpretation correct? $\endgroup$ – Wjx Jun 16 '16 at 12:26
  • $\begingroup$ Related: How to restart a Clock $\endgroup$ – Karsten 7. Jun 16 '16 at 15:55
  • $\begingroup$ These contain solutions to similar problems: mathematica.stackexchange.com/a/96318/18476 & mathematica.stackexchange.com/a/102322/18476 $\endgroup$ – Karsten 7. Jun 16 '16 at 16:17
  • $\begingroup$ Thank you all very much! I'll try them out~ $\endgroup$ – Wjx Jun 16 '16 at 23:52

Your Answer

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

Browse other questions tagged or ask your own question.