How to access "Choose Color Scheme" Programmatically

Do you mean

Button[
 Tooltip["click", 
  Column[{"Click this button to select a ColorScheme.", 
    "This button will be replaced with ColorData"}]],
 With[{box = EvaluationBox[]}, SelectionMove[box, All, Expression];
  FrontEndExecute@
   FrontEnd`AttachCell[box, 
    FrontEndResource["ColorSchemeSelector"], {1, {Right, Top}}, {Left, Top}, 
   "ClosingActions" -> {"SelectionDeparture", "ParentChanged", "EvaluatorQuit"}]]]

GIF


Based on a comment by the OP a PopupMenu might be more suitable.

DynamicModule[{colorScheme = "Rainbow"}, 
 Row[{PopupMenu[Dynamic[colorScheme], 
    Thread[ColorData["Gradients"] -> 
      MapThread[
       Column[{Style[#1, 9], #2}, Left, 0] &, 
       {ColorData["Gradients"],
         LinearGradientImage[#, {700, 100}] & /@ ColorData["Gradients"]}]]], 
   Spacer[10], 
   Dynamic[colorScheme]}]]

GIF2


Here is a modification of Karsten's answer attempting to get the behavior you described in a comment.

  • The selected value is assigned to Global`$color (as shown by Dynamic)
  • I made the picker wider to get rid of the annoying bottom scroll bar

Code:

Button["Pick a color",
 Module[{picker, box = EvaluationBox[]},

  picker = FrontEndResource["ColorSchemeSelector"] /. {
     _FrontEndExecute :> (Global`$color = First @ $CellContext`gsel$$),
     {180, Automatic} -> {195, Automatic}
   };

  SelectionMove[box, All, Expression];

  FrontEnd`AttachCell[box, picker, {1, {Right, Top}}, {Left, Top}
    , "ClosingActions" -> {"SelectionDeparture", "ParentChanged", "EvaluatorQuit"}
  ] // FrontEndExecute

 ]
]

Dynamic[Global`$color]

enter image description here


In a comment below Kuba offered a cleaner implementation using a DialogInput; here is a copy for preservation and easier reading. (comments lose tabulation.)

(Now with a correction from Karsten.)

Button["Pick a color",
  $color =
    DialogInput[
      RawBoxes @ FrontEndResource["ColorSchemeSelector"][[1, 1]] /. {
       _FrontEndExecute :> DialogReturn[First @ $CellContext`gsel$$],
       {180, Automatic} -> {195, Automatic},
       _NotebookDelete  :> DialogReturn[$Canceled]
      }
    ]
  , Method -> "Queued"
]