2

Hello I have found examples of codes that generate palettes to format the text of a cell (or a portion of it). I have also found codes for palettes that change the style of a cell. The latter is described in the Help for instance and gives a nice palette

CreatePalette[
 Column[Button[Style[#, 12, FontFamily -> "Times"], 
     FrontEndTokenExecute[InputNotebook[], "Style", #], 
     Appearance -> "Palette", ImageSize -> 120] & /@ {"Title", 
    "Subtitle", "Subsubtitle", "Section", "Subsection", 
    "Subsubsection", "Text", "Code", "Input"}, Spacings -> 0], 
 WindowTitle -> "Format"] 

Other questions here on MSE such as this do similar things, but still change the text style only.

So I am stuck as I do not find how to modify this function to affect the Background of the Cell.

I would also like to change properties such as the Cell being Editable or Initialization. Again I cannot find the proper command to put in the button to do this.

Eventually I would like to have a button that takes a cell and makes several changes at once, for instance makes the cell initialization, non-editable, and LightGreen background.

Is there a way to edit these properties with a palette?

Thanks for helping, Roberto

Rho Phi
  • 1,420
  • 11
  • 21

1 Answers1

2

Here is a button that will let you toggle between Editable True/False and set the background to red. You should be able to take this and make another button for initialization.

CreatePalette[{
  Button["Editable",
   SelectionMove[InputNotebook[], All, Cell];
   If[Options[NotebookSelection[InputNotebook[]], Editable][[1, 2]] ===
      True,
    SetOptions[NotebookSelection[InputNotebook[]], 
     Editable -> False],
    SetOptions[NotebookSelection[InputNotebook[]], Editable -> True]]
   ],
  Button["Background",
   SelectionMove[InputNotebook[], All, Cell];
   SetOptions[NotebookSelection[InputNotebook[]], Background -> Red];
   ]}]
Mike Honeychurch
  • 37,541
  • 3
  • 85
  • 158
  • Well, Mike this is what I was looking for. Thanks. For some reason my attempt with SetOption of this morning was not successful. I think I can go on my own from now on, thanks a lot for your input. – Rho Phi Feb 14 '14 at 03:43