Widget["ColorChooser"]
provides a panel for making a color selection from various color model interfaces.
Details
Examples
Basic Examples
Generalizations & Extensions
See Also
Tech Notes
Related Links
GUIKit`
GUIKit`
"ColorChooser"
The functionality provided by GUIKit has been superseded by the interface construction and controls functions native to the built-in Wolfram Language.
Widget["ColorChooser"]
provides a panel for making a color selection from various color model interfaces.
Details
- To use Widget["ColorChooser"], you first need to load GUIKit using Needs["GUIKit`"].
- An instance of Widget["ColorChooser"] can be placed within any user interface definition, and you can bind to the chooser's "selectionModel" to be notified whenever the currently selected color changes.
- The following properties are available:
-
"selectionModel" DefaultColorSelectionModel model that intercedes selection operations between the user interface and the data "color" white currently selected color - The "selectionModel" property allows for binding to its "change" event to know when the selected color changes.
Examples
open all close allBasic Examples (1)
Needs["GUIKit`"]ref = GUIRun[
Widget["ColorChooser"]
];GUIScreenShot[ ref]Generalizations & Extensions (1)
Needs["GUIKit`"]Get a Wolfram Language style color primitive by binding to the active selected color:
GUIRunModal[
Widget["Panel", {
Widget["ColorChooser", {
PropertyValue[{"chooser", "selectionModel"}, Name -> "colorSelectionModel"], BindEvent[{"colorSelectionModel", "change"},
Script[updateColor[]]]
}, Name -> "chooser"],
{Widget["TextField", {"text" -> " ", "editable" -> False}, WidgetLayout -> {"Stretching" -> {None, None}}, Name -> "myColorWell"],
Widget["ComboBox", {
"items" -> {"RGBColor", "GrayLevel", "CMYKColor"}, BindEvent["action", Script[updateColor[]]]}, Name -> "myColorModel"],
Widget["TextField", {"text" -> ""}, Name -> "myTextField"]},
Script[
colorExpr = RGBColor[0, 0, 0];
updateColor[] := Module[{newColor},
newColor = PropertyValue[{"colorSelectionModel", "selectedColor"}];
SetPropertyValue[{"myColorWell", "background"}, newColor];
colorExpr = RGBColor[PropertyValue[{newColor, "red"}] / 255., PropertyValue[{newColor, "green"}] / 255., PropertyValue[{newColor, "blue"}] / 255.];
colorExpr = Chop[#, 10 ^ -5]& /@ ToColor[colorExpr, ToExpression[PropertyValue[{"myColorModel", "selectedItem"}]]];
SetPropertyValue[{"myTextField", "text"}, ToString[NumberForm[colorExpr, 5]]];
];
],
BindEvent["endModal", Script[colorExpr]]
}]
]See Also
Tech Notes
Related Links
-
▪
Widget