I was just reminded of an aspect of Maple GUI Components, new to Maple 13, that has sometimes come in very useful to me. It is the ability to refresh a component programatically.

I should explain. The old (and current default) behaviour is for the GUI not to refresh any other components until the current component is finished (ie. returns control).

The relevant situation in which this matters is when a given component has action code whose intended use is to augment some other component repeatedly. Typically, the given component is a Button and the other component is a Math container (for output).

However, if the Button is supposed to gradually update the Math container with new values then it's of no use if the updates don't happen until the Button returns control. In Maple 13, there is a way to update a value of a component and have it immediately refresh regardless of whether control returns.

Here is an illustrative example for use in Maple 13. Create a Math container component named MathContainer0. Then put the following code in a  Button component ("Action When Clicked" in the Button's Component Properties). The code uses a wall-clock delay, to illustrate the progressive update effect.

R := Statistics:-Sample(Statistics:-RandomVariable(

for i from 1 to 4 do
  DocumentTools:-SetProperty(MathContainer0, 'value', R[i],
                             'refresh'=true );
  while time[real]()-st < 2 do end do;
end do:

In Maple 12, using DocumentTools:-Do instead of DocumentTool:-SetProperty, the Math container would get no visible update while the code ran for 8 seconds. Then it would flash all four random values rapidly, one after another, when the Button finished its action. But with the above method, the Math container visibly displays four random values printed as 2 second intervals.

The functionality relies on using DocumentTools:-SetProperty rather than DocumentTools:-Do. (It might be nice if the latter also had this functionality added.)


Please Wait...