Function Repository Resource:

 DeleteAllOutputPalette

Source Notebook

Create a palette for conveniently deleting all the output and the print cells in a notebook

Contributed by: Jayanta Phadikar and Kunal Khadke

ResourceFunction["DeleteAllOutputPalette"][]

creates a palette with a button to delete all the output and the print cells in the selected notebook.

ResourceFunction["DeleteAllOutputPalette"][nb]

creates a palette specific to the notebook nb.

Details and Options

The built-in method for deleting all the output cells is to use Cell ▶ Delete All Output. The palette provides a more convenient and aesthetically pleasing way to delete the output/print cells during a presentation.
The button does not delete the output cells that have the option GeneratedCell→False set.
The Generated Cell button in the palette can be used to set GeneratedCell→False for the selected cells.
Options for ResourceFunction["DeleteAllOutputPalette"]:
Magnification1.75change palette size
"ShowGeneratedCellButton"Falseshow Generated Cell button in the palette

Examples

Basic Example: (2) 

Create the palette:

In[1]:=
ResourceFunction["DeleteAllOutputPalette"][]
Out[1]=

Evaluate the example expressions below:

In[2]:=
Manipulate[Plot[Sin[x (1 + a x)], {x, 0, 6}], {a, 0, 2}, ControlPlacement -> Top]
In[3]:=
Plot[Sin[x], {x, 0, 6 Pi}]
In[4]:=
Do[Print[i], {i, 1, 10, 3}]

Click on the button in the palette to remove all the output/print cells.

Scope: (2) 

Open a new notebook:

In[5]:=
nb = NotebookOpen[
   FileNameJoin[{$InstallationDirectory, "Documentation", "English", "System", "ExampleData", "document.nb"}]];

Create a palette specific to the notebook above:

In[6]:=
ResourceFunction["DeleteAllOutputPalette"][nb]
Out[6]=

Options: (3) 

Magnification (1) 

Change the palette size with the option Magnification:

In[7]:=
ResourceFunction["DeleteAllOutputPalette"][Magnification -> 1]
Out[7]=

ShowGeneratedCellButton (2) 

Show a Generated Cell button in the palette using the "ShowGeneratedCellButton" option:

In[8]:=
ResourceFunction["DeleteAllOutputPalette"][Magnification -> 1, "ShowGeneratedCellButton" -> True];

Select an output from the following cells and mark it as a generated cell using the Generated Cell button. Then, clicking the delete button will not delete the marked cells:

In[9]:=
Plot[Sin[x], {x, 0, 10 Pi}]
Out[9]=
In[10]:=
Print["Hello World"]

Possible Issues: (1) 

If certain cells should not be deleted by the button, you can set the option GeneratedCell→False. The following Manipulate output will not be deleted by the aforementioned method:

In[11]:=
Manipulate[Factor[x^n + 1], {n, 10, 100, 1}]
Out[11]=
In[12]:=
SetOptions[PreviousCell[], GeneratedCell -> False]

Publisher

Kunal Khadke

Version History

  • 1.0.0 – 21 September 2021

Related Resources

License Information