Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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];
   ]}]
share|improve this answer
    
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. –  Roberto Franceschini Feb 14 at 3:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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