Creating Advanced Maplets Using the Maplet Builder
To start the Maplet Builder, from the Tools menu, select Assistants, and then Maplet Builder.
To learn more about the structure of the Maplet Builder, see the Overview of the Maplet Builder help page.
To learn more about the elements available when designing a Maplet, see the Overview of the Palette Pane help page.
General Information
When dragging elements to the Layout pane, the active region is highlighted.
Elements are referenced using names of the form Button1, Slider1, and BoxColumn1 in the Maplet Builder. To assign an informative name, change the reference property for the element in the Properties pane.
In the Evaluate Expression window, accessed by selecting <Evaluate> in the onclick or onchange property of select elements, enter element names in the expression, function, or argument field by double-clicking the element from the List window.
When entering functions, do not end the statement with a semi-colon (;).
Accessing user-defined procedures from the Maplet Builder is not possible. Refer to Example 2: Calling a User-defined Procedure for a workaround.
The Maplet Builder supports only single window Maplets.
Example 1: Advanced Example - Animating a Plot
This Maplet displays a plot with buttons to play, pause, and stop the animation.
Maplet Image
Steps
Start a new Maplet and set the layout
1. From the File menu, select New.
2. In the Properties pane,
* from the drop-down menu, select BoxColumn1.
* change the numrows property to 2.
First row
1. Drag the Plotter element to the first row in the Layout pane.
2. In the Properties pane, * double-click the background property and select white in the Color dialog. Click Ok to return to the Maplet Builder.
* in the value property, enter plots[animate]( plot, [(x-A)^2-1,x=-4..4], A=-2..2 ). Note: Do not end the plot command with a semi-colon (;).
Second row: Left column
1. In the Properties pane,
* from the drop-down menu, select BoxRow2.
* change the numcolumns property to 3.
2. Drag the Button element to the left column in the Layout pane.
3. In the Properties pane,
* from the drop-down menu, select Button1.
* in the caption property, enter Play.
* in the onclick property, select <SetOption> to display the Set Option dialog.
In the Set Option dialog,
* from the Target drop-down menu, select Plotter1.
* from the Option drop-down menu, select play.
* in the Value field, enter true.
* click Ok to return to the Maplet Builder.
Second row: Center column
1. Drag the Button element to the middle column in the Layout pane.
* from the drop-down menu, select Button2.
* change the caption property to Pause.
* from the Option drop-down menu, select pause.
Second row: Right column
1. Drag the Button element to the right column in the Layout pane.
* from the drop-down menu, select Button3.
* change the caption property to Stop.
* from the Option drop-down menu, select stop.
3. From the File menu, select Run.
Example 2: Advanced Example - Calling a User-defined Procedure
This Maplet calls the user-defined procedure Plotting when the user clicks the Plot button.
To access the user-defined procedure from this Maplet:
1. Use the Maplet Builder as described in the following Steps section, define and save the Maplet as a .maplet file.
2. Use the Maple commands in the Worksheet subsection (at the end of the Steps section), define the procedure.
3. Load the Maplet using one of the following methods.
* The read command at the end of the Worksheet subsection.
* From the File menu, select Open. Navigate to and open the saved .maplet file. This will display the Maplet code in the worksheet. Execute the code to launch the Maplet.
* from the drop-down menu, select BoxLayout1.
* in the numrows property, enter 3.
First and second row
* from the drop-down menu, select Plotter1.
* double-click the background color and select white from the Color dialog. Click Ok.
3. Drag the MathMLEditor element to the second row in the Layout pane.
Third row
* from the drop-down menu, select BoxRow3.
* in the numcolumns property, enter 3.
* in the caption property, enter Plot.
* in the onclick property, select <Evaluate> to display the Evaluate Expression window.
In the Evaluate Expression window,
* change the Target field to Plotter1.
* verify the Option field is set to value.
* in the Expression window, enter the name of your defined function, Plotting.
4. Drag the Button element to the right column in the Layout pane.
5. In the Properties pane,
* in the caption property, enter Close.
* from the onclick property, select <Shutdown> to display the Shutdown Event dialog.
In the Shutdown Event dialog,
6. From the File menu, select Save. Save the Maplet as Example2 in the C:\Maple directory.
Worksheet
Plotting:=proc() local R, G, B, result; use Maplets[Tools] in # retrieve the function entered in the MathMLEditor region and plot the result plot(MathML:-Import(Get(MathMLEditor1)), x=0..10); end use: end proc:
read( FileTools:-JoinPath( [ kernelopts(datadir), "help", "MapletBuilder", "Example2.maplet" ] ) );
Example 3: Advanced Example - GridLayout within a BoxLayout
The final Maple shows how to define a GridLayout region within a BoxLayout scheme.
* in the numrows property, enter 2.
* from the drop-down menu, select Plotter1
* double-click the background property and select white in the Color dialog.
Second row: Define GridLayout
1. Expand the Layout palette by clicking the arrow in the left corner.
2. From the Layout palette, drag the GridLayout element to the second row in the Layout pane.
* from the drop-down menu, select GridLayout1
* change the border property to true.
Second row: First grid row
1. From the Layout palette, drag the GridCell element to the first row of the GridLayout region in the Layout pane. Ensure that you place the cell inside the GridRow element.
2. Drag the Button element to the GridCell in the Layout pane.
* change the caption property to sin(x).
* in the onclick property, select <Evaluate>.
In the Evaluate Expression dialog,
* enter plot(sin(x), x=0..10).
4. Drag the GridCell element to the right of the defined button labeled sin(x) in the Layout pane.
5. Drag the Button element to the GridCell in the Layout pane.
6. In the Properties pane,
* change the caption property to exp(x).
* enter plot(exp(x), x=0..10).
Second row: Second grid row
1. Drag the GridCell element to the second row of the GridLayout region in the Layout pane.
2. Drag the Button element to the GridCell region in the Layout pane.
* change the caption property to cos(x).
* enter plot(cos(x), x=0..10).
4. Drag the Button element to the GridCell region in the Layout pane. Drag the GridCell element to the right of the defined button labeled cos(x) in the second row.
* from the drop-down menu, select Button4.
* change the caption property to ln(x).
* enter plot(ln(x), x=0..10).
6. From the File menu, select Run.
Return to Example Worksheet Index
Download Help Document