I have this code. When I click on the clock, my alarm don't activate and not work. I have tried with DynamicModule
and nothing. I don't know where is the error.
reloj = Dynamic[
Refresh[ClockGauge[DateString["Time"], ImageSize -> 120,
LabelStyle -> {Darker@Black, 10.5, Bold},
GaugeStyle -> {Red, Red, Black}, PlotTheme -> "Minimal",
TicksStyle -> Directive[Black, Bold], LabelStyle -> Bold,
GaugeLabels -> {"ROLEX", Placed[ "AMPM", {0.5, 0.35}]},
GaugeMarkers -> "ThinArrowNeedle"], UpdateInterval -> 1]];
sound = EmitSound@
Import[NotebookDirectory[] <> "alarmbeep.mp3", "Sound"];
alarma = Dynamic@
Panel[Row[{Column[{Control[{{h, "", "Hours"}, Range[25] - 1}],
Control[{{m, "", "Minutes"}, Range[61] - 1}],
Control[{{oo, True, "Alarm"}, {True -> "ON",
False -> "OFF"}}]}],
If[Refresh[DateList[], UpdateInterval -> 1][[4 ;; 5]] == {h,
m} && oo, sound]}], Background -> LightBlue];
EventHandler[reloj,
"MouseClicked" :>
Quiet@CreateDialog[Column[{Panel[alarma], ChoiceButtons[]}],
WindowTitle -> "CONFIGURE LA ALARMA"]]
sound
should be defined usingSetDelayed
instead ofSet
as theEmitSound
is part of the definition ofsound
. Or you should callEmitSound
insideDynamic
. $\endgroup$Dynamic@Panel[ Row[{Column[{Control[{{h, "", "Hours"}, Range[25] - 1}], Control[{{m, "", "Minutes"}, Range[61] - 1}], Control[{{oo, True, "Alarm"}, {True -> "ON", False -> "OFF"}}]}], If[Refresh[DateList[], UpdateInterval -> 1][[4 ;; 5]] == {h, m} && oo, EmitSound@ Import[NotebookDirectory[] <> "alarmbeep.mp3", "Sound"]]}], Background -> LightBlue]
$\endgroup$