Skip to main content
Improved formatting
Source Link
Clif
  • 687
  • 4
  • 13
 Manipulate[ Pane[Column[{Text[ Row[If[n < 2, {Spacer[160], Style[nnames[[n]], Bold, Large, Hue[RandomReal[]]], Style[" Ball", Bold, Large, Green]}, {Spacer[160], Style[nnames[[n]], Bold, Large, Hue[RandomReal[]]], Style[" Balls", Bold, Large, Green]}]]], Row[Table[ Graphics[{Darker[Green], Disk[], Text[Style[numerals[[r]], Orange, "Label", 48], {0, 0}]}], {r, 1, n}]], Speak[n], Pause[1], choiceEnabled = True;}, BaseStyle -> {LinebreakAdjustments -> {1., 10, 0, 0, 10}}], {525, 300}], Row[{Button[ " Start \n ", {If[n < 2, "", {n = 1, Speak["lets count the numbers 1 to 9 out loud"], choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Spacer[55], Button[ "\[FilledLeftTriangle]\[FilledLeftTriangle] Start Over", {If[ n < 2, "", {n = 1, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Button[ "\[FilledLeftTriangle] Less", {If[ n < 2, {n = 1, Speak["Today we are just working on the numbers from one to \ nine."], Pause[3]}, {n -= 1, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Spacer[10], Button["More \[FilledRightTriangle]", {If[ n > 8, {n = 9, Speak["Lets learn the numbers from one to nine before we go \ on."], Pause[3]}, {n += 1, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Button[ "All \[FilledRightTriangle]\[FilledRightTriangle]", {If[n > 8, "", {n = 9, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]]}], {{n, 9, " "}, ControlType -> None}, Initialization :> (numerals = {"1", "2", "3", "4", "5", "6", "7", "8", "9"}; nnames = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"}; choiceEnabled = True;)] 

Pane[Column[{Text[ Row[If[n < 2, {Spacer[160], Style[nnames[[n]], Bold, Large, Hue[RandomReal[]]], Style[" Ball", Bold, Large, Green]}, {Spacer[160], Style[nnames[[n]], Bold, Large, Hue[RandomReal[]]], Style[" Balls", Bold, Large, Green]}]]], Row[Table[ Graphics[{Darker[Green], Disk[], Text[Style[numerals[[r]], Orange, "Label", 48], {0, 0}]}], {r, 1, n}]], Speak[n], Pause[1], choiceEnabled = True;}, BaseStyle -> {LinebreakAdjustments -> {1., 10, 0, 0, 10}}], {525, 300}], Row[{Button[ " Start \n ", {If[n < 2, "", {n = 1, Speak["lets count the numbers 1 to 9 out loud"], choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Spacer[55], Button[ "[FilledLeftTriangle][FilledLeftTriangle] Start Over", {If[ n < 2, "", {n = 1, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Button[ "[FilledLeftTriangle] Less", {If[ n < 2, {n = 1, Speak["Today we are just working on the numbers from one to
nine."], Pause[3]}, {n -= 1, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Spacer[10], Button["More [FilledRightTriangle]", {If[ n > 8, {n = 9, Speak["Lets learn the numbers from one to nine before we go
on."], Pause[3]}, {n += 1, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Button[ "All [FilledRightTriangle][FilledRightTriangle]", {If[n > 8, "", {n = 9, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]]}], {{n, 9, " "}, ControlType -> None}, Initialization :> (numerals = {"1", "2", "3", "4", "5", "6", "7", "8", "9"}; nnames = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"}; choiceEnabled = True;)]

Manipulate[ 

Pane[Column[{Text[ Row[If[n < 2, {Spacer[160], Style[nnames[[n]], Bold, Large, Hue[RandomReal[]]], Style[" Ball", Bold, Large, Green]}, {Spacer[160], Style[nnames[[n]], Bold, Large, Hue[RandomReal[]]], Style[" Balls", Bold, Large, Green]}]]], Row[Table[ Graphics[{Darker[Green], Disk[], Text[Style[numerals[[r]], Orange, "Label", 48], {0, 0}]}], {r, 1, n}]], Speak[n], Pause[1], choiceEnabled = True;}, BaseStyle -> {LinebreakAdjustments -> {1., 10, 0, 0, 10}}], {525, 300}], Row[{Button[ " Start \n ", {If[n < 2, "", {n = 1, Speak["lets count the numbers 1 to 9 out loud"], choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Spacer[55], Button[ "[FilledLeftTriangle][FilledLeftTriangle] Start Over", {If[ n < 2, "", {n = 1, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Button[ "[FilledLeftTriangle] Less", {If[ n < 2, {n = 1, Speak["Today we are just working on the numbers from one to
nine."], Pause[3]}, {n -= 1, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Spacer[10], Button["More [FilledRightTriangle]", {If[ n > 8, {n = 9, Speak["Lets learn the numbers from one to nine before we go
on."], Pause[3]}, {n += 1, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Button[ "All [FilledRightTriangle][FilledRightTriangle]", {If[n > 8, "", {n = 9, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]]}], {{n, 9, " "}, ControlType -> None}, Initialization :> (numerals = {"1", "2", "3", "4", "5", "6", "7", "8", "9"}; nnames = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"}; choiceEnabled = True;)]

 Manipulate[ Pane[Column[{Text[ Row[If[n < 2, {Spacer[160], Style[nnames[[n]], Bold, Large, Hue[RandomReal[]]], Style[" Ball", Bold, Large, Green]}, {Spacer[160], Style[nnames[[n]], Bold, Large, Hue[RandomReal[]]], Style[" Balls", Bold, Large, Green]}]]], Row[Table[ Graphics[{Darker[Green], Disk[], Text[Style[numerals[[r]], Orange, "Label", 48], {0, 0}]}], {r, 1, n}]], Speak[n], Pause[1], choiceEnabled = True;}, BaseStyle -> {LinebreakAdjustments -> {1., 10, 0, 0, 10}}], {525, 300}], Row[{Button[ " Start \n ", {If[n < 2, "", {n = 1, Speak["lets count the numbers 1 to 9 out loud"], choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Spacer[55], Button[ "\[FilledLeftTriangle]\[FilledLeftTriangle] Start Over", {If[ n < 2, "", {n = 1, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Button[ "\[FilledLeftTriangle] Less", {If[ n < 2, {n = 1, Speak["Today we are just working on the numbers from one to \ nine."], Pause[3]}, {n -= 1, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Spacer[10], Button["More \[FilledRightTriangle]", {If[ n > 8, {n = 9, Speak["Lets learn the numbers from one to nine before we go \ on."], Pause[3]}, {n += 1, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Button[ "All \[FilledRightTriangle]\[FilledRightTriangle]", {If[n > 8, "", {n = 9, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]]}], {{n, 9, " "}, ControlType -> None}, Initialization :> (numerals = {"1", "2", "3", "4", "5", "6", "7", "8", "9"}; nnames = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"}; choiceEnabled = True;)] 
Source Link
Clif
  • 687
  • 4
  • 13

This is not the perfect solution to the problem, however the behavior of the manipulate is improved over what it was in the original question. Thanks to all who looked at this and especially David Park who gave me the “choiceEnabled =True/False” as well as all who left comments. I am not going to accept this as “The Answer”, in hopes that someone will eventually post a really good way to synchronize the audio and the graphics in general. As for this solution I feel like one of the keys was to place the “Speak” and “Pause” statements after the graphics, forcing the program to read through the graphics before encountering the “Pause”.

Manipulate[ 

Pane[Column[{Text[ Row[If[n < 2, {Spacer[160], Style[nnames[[n]], Bold, Large, Hue[RandomReal[]]], Style[" Ball", Bold, Large, Green]}, {Spacer[160], Style[nnames[[n]], Bold, Large, Hue[RandomReal[]]], Style[" Balls", Bold, Large, Green]}]]], Row[Table[ Graphics[{Darker[Green], Disk[], Text[Style[numerals[[r]], Orange, "Label", 48], {0, 0}]}], {r, 1, n}]], Speak[n], Pause[1], choiceEnabled = True;}, BaseStyle -> {LinebreakAdjustments -> {1., 10, 0, 0, 10}}], {525, 300}], Row[{Button[ " Start \n ", {If[n < 2, "", {n = 1, Speak["lets count the numbers 1 to 9 out loud"], choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Spacer[55], Button[ "[FilledLeftTriangle][FilledLeftTriangle] Start Over", {If[ n < 2, "", {n = 1, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Button[ "[FilledLeftTriangle] Less", {If[ n < 2, {n = 1, Speak["Today we are just working on the numbers from one to
nine."], Pause[3]}, {n -= 1, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Spacer[10], Button["More [FilledRightTriangle]", {If[ n > 8, {n = 9, Speak["Lets learn the numbers from one to nine before we go
on."], Pause[3]}, {n += 1, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]], Button[ "All [FilledRightTriangle][FilledRightTriangle]", {If[n > 8, "", {n = 9, choiceEnabled = False}]}, Enabled -> Dynamic[choiceEnabled]]}], {{n, 9, " "}, ControlType -> None}, Initialization :> (numerals = {"1", "2", "3", "4", "5", "6", "7", "8", "9"}; nnames = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"}; choiceEnabled = True;)]