insert a button in a Standard Maple worksheet or document
Component Palette Image
Button Component Examples
The button component performs an action or a series of actions to communicate with other embedded components when the button is selected, although assigning an action to a component is not required. The button component can display a caption or an image.
To perform an action when a button is clicked, select the button, and then in the Button context panel, select Edit Click Code to open the Code Editor dialog for the button. Enter the commands you want to perform in the Code Editor dialog.
You need to specify one or more embedded components that will display the output of the button click. For more information, see the Button Component Examples on this page.
The button component is customized by setting options in the Button context panel. To view the Button context panel, select the button component.
Actions are associated with components using routines in the DocumentTools package.
The Name property is used to reference the button when using the routines from the DocumentTools package.
By default, the size of the button is determined from the length of the caption or the size of the selected image, in the case when you are displaying an image. To set a specific size, click Scale to a specific size and set the width and height in pixels. If you are displaying an image, the image is rescaled to that size.
When using the Fill Color property, you should ensure that Draw border is not selected.
The following table describes the control and use of the button component options.
An x in the Get column indicates that the option can be read, that is, retrieved by using the DocumentTools[GetProperty] tool.
An x in the Set column indicates that the option can be written, that is, set by using the DocumentTools[SetProperty] tool.
true or false
name or string
The caption that appears on the button. By default, the value is Button.
The click action code that executes when the button is pressed.
Whether a button can be clicked. If enabled is set to false, the button is grayed out and any action associated with it cannot be initiated. By default, the value is true.
Specifies the background color of the component. The color can be given by RGB values (a list of three integers between 0 and 255) or a string representing a color name, for example, [255,0,0] or “Red”. When using fillcolor, ensure that showborders is false.
If not specified, the background color is gray.
Specifies the font color of the component. The default value is [0,0,0] which corresponds to black.
The image that appears on the button. If both an image and a caption are specified, the image takes precedence.
When image is used, the height of the button in pixels.
When image is used, the width of the button in pixels.
Indicates if the border of the button is shown. This only affects a button with a caption. By default, the value is true.
The text that appears when the user hovers the mouse over the button.
The type of the component. This returns "Button".
Whether the specified size of the button is used. By default, the value is false.
Specifies if the button is visible. By default, the value is true.
Note: To interact with the examples provided below, open this help page as a worksheet and then execute the worksheet.
Example 1 - Display a plot of sin(x) in blue by clicking a button using embedded components.
To place the components and configure the plot component:
Insert a Plot and Button component using the Components palette. For information on displaying the Maple palettes, see the Show Palettes help page.
Click on the Plot component to display the Plot context panel on the right side of the worksheet (or document).
In the Plot Expression region, enter plot(sin(x), x=0..10);
The Plot component plots sin(x) in the default color (burgundy).
To display a caption on the button:
Click on the Button component to display the Button context panel.
In the Caption field, enter Blue Plot.
To edit the action of the button when it is clicked:
Click on Blue Plot, and then select Edit Click Code.
This launches the Code Editor dialog.
Before the end use; statement in the dialog, enter the following command:
SetProperty("Plot0", value, plot( sin(x), x=0..10, color=blue));
Note: Ensure the component name (that is, Plot0) is correct.
on the Code Editor toolbar or from the File menu, select Save Code to accept all changes.
From the File menu, select Close Code Editor.
When you click Blue Plot, the color of the plot changes to blue.
You can verify the syntax of the embedded component action by executing the command in the worksheet.
SetProperty("Plot0", value,plot(sin(x), x=0..10, color = blue));
Example 2 - Launch the ArcLengthTutor and return the plot output in an embedded Plot component.
Insert a Plot, Label, and Button component in the worksheet.
Click the Label component to display the context panel.
In the Caption field, enter Launch the Arc Length Tutor.
Click the Button component to display the context panel.
In the Caption field, enter Run Tutor.
Click Run Tutor, and then select Edit Click Code from the context panel.
SetProperty("Plot1", value, "Student[Calculus1][ArcLengthTutor]()");
Note: Ensure the component name matches the name of the Plot component.
Download Help Document
What kind of issue would you like to report? (Optional)