Radio Button Component
insert a radio button in a worksheet or document
Description
Component Palette Image
Radio Button Properties
Radio Button Component Example
The radio button component performs an action or a series of actions to communicate with other embedded components when the radio button is selected, although assigning an action to a component is not required.
To perform an action when a radio button is selected, select the radio button, and then select Edit Click Code to open the Code Editor dialog for the radio 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 radio button selection. For more information, see the Radio Button Component Example on this page.
The radio button component is customized by setting options in the Radio Button context panel. To view the Radio Button context panel, select the toggle button. Actions are associated with components using routines in the DocumentTools package.
The Name property is used to reference the radio button when using the routines from the DocumentTools package.
The Group Name property is used to automatically group components of the same name. The default group name for the radio button component is Group0. When a component is grouped, all components of the same group name will automatically be de-selected when one is selected. Only the Maple code attached to the selected component of the group will be executed. The following components can be added to a group: Check Box Component and Toggle Button Component.
You can de-select a radio button by clicking another radio button in the same group, in the same Maple worksheet. You can also select another radio button programmatically by specifying the command DocumentTools[SetProperty](<radio_button_name>,value,true).
The following table describes the control and use of the radio 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.
Option
Get
Set
Option Type
caption
x
string
enabled
true or false
fillcolor
color
fontcolor
groupname
tooltip
type
value
visible
The caption that appears on the component.
Whether the component is enabled. If enabled is set to false, the radio 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”. The default value is [255,255,255] which corresponds to white.
Specifies the font color of the component. The default value is [0,0,0] which corresponds to black.
The name of the component group.
The text that appears when the user hovers the mouse over the component.
The type of the component. This returns "RadioButton".
Specifies if the radio button is selected. By default, the value is false.
Specifies if the radio 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.
This example shows how to apply scaling to a plot using a Plot embedded component and two radio buttons.
To insert the components and configure the Plot:
Insert a Plot component and two Radio Button components using the Components palette. For information on displaying the Maple palettes, see the Show Palettes help page.
Click the Plot component, and then select Component Properties.
In the Plot Expression field, enter plot(x^2*cos(x), x=-Pi..Pi);
To change the scaling of the plot to constrained by clicking on the first Radio Button:
Click the first Radio Button component, and then select Component Properties.
In the Caption field, enter Constrained.
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(x^2*cos(x), x=-Pi..Pi, scaling=constrained));
Note: Ensure the component name (that is, Plot0) is correct.
Click or from the File menu, select Save Code to accept all changes.
From the File menu, select Close Code Editor.
To change the scaling of the plot to unconstrained by clicking on the second Radio Button:
Click the second Radio Button component to open the context panel.
In the Caption field, enter Unconstrained.
Select Edit Click Code to launch the Code Editor dialog.
SetProperty("Plot0", value, plot(x^2*cos(x), x=-Pi..Pi, scaling=unconstrained)); Note: Ensure the component name (that is, Plot0) is correct.
Selecting the appropriate radio button changes the scaling of the plot to either constrained or unconstrained. Note that radio buttons were both in the same default group when they were inserted; this ensures that only one radio button can be selected at a time.
See Also
DocumentTools
DocumentTools[GetProperty]
DocumentTools[SetProperty]
EmbeddedComponents
Maplets[Elements][RadioButton]
Download Help Document