MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Clear cell labels palette

  • To: mathgroup at
  • Subject: [mg48879] Re: [mg48791] Clear cell labels palette
  • From: Omega Consulting <info at>
  • Date: Tue, 22 Jun 2004 05:31:13 -0400 (EDT)
  • References: <>
  • Sender: owner-wri-mathgroup at

In[1]:= ?EvaluationNotebook
EvaluationNotebook[ ] gives the notebook in which this
function is being evaluated.

In[2]:= ?InputNotebook
InputNotebook[ ] gives the current notebook into which
keyboard input in the front end will be directed.

What does that mean?

The InputNotebook is pretty straight-forward. If you started typing, 
where would the input appear? It's typically used with palettes. Since 
palettes do not accept input, the InputNotebook is the topmost 

EvaluationNotebook is the notebook of the current evaluation. It is 
typically used in code cells, not buttons, to refer to the notebook 
that contains the code. So I think this is a poorly written example.

What you're seeing is that in some situations the target notebook is 
treated as the EvaluationNotebook. In others, it's the palette. That 
strikes me as silly since the button doesn't contain any kernel 
evaluations (ButtonEvaluator -> None so this is done by the frontend). 
But then again, asking for the EvaluationNotebook from a button also 
seems silly. Garbage in, garbage out, I guess.

If you change it to use ButtonEvaluator->Automatic (i.e. use the kernel 
not the frontend), you can see what's happening. Now when you press the 
button, you'll see "Running..." in the title bar of the 

It seems dangerous to me that the EvaluationNotebook depends on the 
selection. I often work with different versions of the kernel. I do 
this by adding kernels (Kernel>KernelConfigurartion Options menu). Then 
I can set a notebook to use that kernel (Kernel>Notebook's Kernel). So 
depending on the selection, the button will use the palette's kernel or 
the notebook's kernel. That doesn't make a lot of sense to me.

On Jun 16, 2004, at 3:55 AM, Ingolf Dahl wrote:

> To MathGroup,
> In Mathematica Help, on "ButtonBox", among "Further Examples", there 
> is one
> example:
> "Evaluate the following cell to create the button ?Clear cell labels?. 
> Click
> on the button to remove all cell labels from this notebook. "
> ButtonBox[StyleBox["Clear cell labels", FontFamily -> "Helvetica"],
>     ButtonFunction :>
>       FrontEndExecute[{SelectionMove[EvaluationNotebook[], All, 
> Notebook],
>           SetOptions[NotebookSelection[EvaluationNotebook[]],
>             CellLabel -> ""]}], ButtonEvaluator -> None,
>     Active -> True] // DisplayForm
> Such a button is convenient if you restart the Kernel. So I evaluated 
> this
> to create a button. Then I selected the button, applied "Generate 
> Palette
> from Selection" and saved the palette under the directory
> $UserBaseDirectory\Applications\Palettes\FrontEnd\Palettes. Then I can
> easily load this palette from "Palettes". So long everything worked 
> out OK.
> But when I used this palette button it did not work every time. I had 
> to
> select the content of a cell or a part of the content of a cell for it 
> to
> function. If I only select the notebook or a whole cell in the 
> notebook, or
> have the insertion point between two cells, the palette button does not
> work. Something with the command SelectionMove[EvaluationNotebook[], 
> All,
> Notebook] seems to affect this. (I have Mathematica 5.0.1 on a Windows 
> Me
> mashine). If I replace EvaluationNotebook[] with InputNotebook[], the 
> button
> works much better. Thus, try to make a palette of
> ButtonBox[StyleBox["Clear cell labels", FontFamily -> "Helvetica"],
>     ButtonFunction :>
>       FrontEndExecute[{SelectionMove[InputNotebook[], All, Notebook],
>           SetOptions[NotebookSelection[InputNotebook[]],
>             CellLabel -> ""]}], ButtonEvaluator -> None,
>     Active -> True] // DisplayForm
> and store it in the way outlined before, if you need it.
> Can someone explain to me what was wrong with the use of
> EvaluationNotebook[] in this button?
> Have fun!
> Ingolf Dahl
> Sweden

Omega Consulting
The final answer to your Mathematica needs.

  • Prev by Date: Condition generation for complex integrals
  • Next by Date: basic question about plotting 2 functions in one graph
  • Previous by thread: Clear cell labels palette
  • Next by thread: Using NDSolve in NonlinearFit