2
$\begingroup$

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

$\endgroup$

1 Answer 1

2
$\begingroup$

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];
   ]}]
$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$
    – Rho Phi
    Commented Feb 14, 2014 at 3:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.