notebooks – Formatting Mathematica Input

As an example, I am using code from the link below.

Usually such code has no line breaks and expands to fill the available width. Please visit the link to see this effect, assuming that it is not clear from my explanation.

 Evaluate(ElectroStaticPotential({1, -1}, {{-1, 0, 0}, {1, 0, 0}}, {x,
     y, z})), {x, -6, 6}, {y, 0, 4}, {z, -4, 4}, 
 Contours -> {-0.75, -0.25, -0.1, 0, 0.1, 0.25, 0.75}, 
 ContourStyle -> Table(Hue(i/7), {i, 0, 6}), Mesh -> None)

Is there a way to format it from the notebook interface (or by using some available package) for readability/inclusion in a limited character column space/book etc?

  ElectroStaticPotential({1, -1},
   {{-1, 0, 0}, {1, 0, 0}}, {x, y, z})
 {x, -6, 6}, {y, 0, 4}, {z, -4, 4},
 Contours -> {-0.75, -0.25, -0.1, 0, 0.1, 0.25, 0.75},
 ContourStyle -> Table(Hue(i/7), {i, 0, 6}),
 Mesh -> None

I guess it is part of the larger question: “Are there any published guidelines for formatting Mma code?”

Your help is appreciated.

notebooks – Locking cell groups

Imagine I have a notebook divided into multiple groups of code cells which are set as initialization groups. I then have a single cell which evaluates a function program() that yields an interactive tool (for example via Manipulate) which internal functions are defined in the initialization groups. Something like

enter image description here

If these groups are collapsed, is it possible to lock them so that when I share the notebook the code in these groups remains hidden and private and the only accessible cell is the one to run the program?

notebooks – In my stylesheet how to change number color to red?

I would like to have a notebook stylesheet which colors any number e.g., {1,2,{3}} red. I tried Preferences ,Appearance, LocalVariables etc.but there numbers stay black. How can I change my stylesheet? I also could not find it in previous answers to changing color.

searching – Intelligent text search on large directories of notebooks?

I have a (deeply nested) directory containing 10s of thousands of wolfram files (mostly notebooks (nbs), but also scripts (.wls), packages (.m, .q
wl), my and wxf data) and many subfolders each with a few hundred notebooks on average. Each notebook contains 10-100 of pages. I want to search on text in the files and within relacant notebook cells types e.g. Code, Text, Title, SubTitle, Item, Program, ExternalLanguage, etc.

I’d like to have a live search interface to quickly search through the contents of all files and visually show the matches highlighted within their context.

Is there an existing project or best practices for doing this?

The TextSeach related wolfram symbols are old and seem slow/weak, can mma even do this? Mma is obviously needed to preview the content of matches within notebooks, but what other tools would be used to build such a live deep search?

python – Preview Jupyter Notebooks in Ubuntu

Peeking at Jupyter notebooks is a long process, need to cd to the file location and need to run jupyter notebook to start the server and get things done, but I don’t need to edit or work with it. Is there any other possible way to just take a look at notebooks quickly?

Looking for the Linux equivalent of this tuxu/nbviewer

PS: Already know about a Firefox extension but it is broken now.

graphics – Drawing on screen outside notebooks

Is there a way to display (animated) graphics outside of Mathematica notebooks, i.e., in a specified rectangle on the screen? I can imagine that one way to achieve that is by creating a notebook without borders, menu, or any other elements, and configuring it such that it stays always on top. Can this be achieved?

Persistent hyperlinks between notebooks in the same directory

Assume that I have two notebooks, one named A.nb, and the other named B.nb, and that they are in the same directory. Then, I create a link to the notebook B.nb in the notebook A.nb. Next, I rename B.nb to C.nb. This breaks the link to notebook B.nb in the notebook A.nb.

Are there any ways to create hyperlinks between notebooks (preferably in the same directory) that persist through file name changes? Is is possible to use the notebook’s metadata, for example, the unique ID number, to create the link, since this should persist through a name change? Thanks!

notebooks – .nb file containing large data is not saved correctly

I created a large list of real numbers and saved it to Tes.nb

Tes = Sort[RandomReal[{-7., 7.}, 1000000]]

But I noticed the size of Tes.nb file was merely 10 KB.

Thinking strangely, I opened the Tes.nb file and clicked ‘show all button’.

enter image description here

It showed an error message :

$OutputSizeLimit : …

The data has disappeared literally.

It is surprising and disappointing that mathematica didn’t warn anything when saving .nb file.

How can I save large data correctly ?

Why didn’t mathematica warn anything ?

notebooks – Pasting multiline commands

If i copy and paste something from one nb to another it works normally.

enter image description here

But if I copy from any other app it just puts everything in the same line.

enter image description here

Recently, I have automated my workflow in Mathematica with Touch Portal and Razer Naga sinapse 3. I have manny commands as long as this one below.

enter image description here

Those long commands become very unreadable when put into a single line.

Is there a way to make pasting work normally?

python – Using 2 sets of tkinter notebooks to display different frames of an instance

I am creating a server management app where I would like to control several servers at once, I have the app working for a single instance but I am now trying to add functionality to control more than 1 server at a time.

I would like to be able to see server status, settings, backups etc for each server, I have come up with this design which uses tabs on the left for each “page” and tabs across the top for each server:

enter image description here

how can I detect which page to show? I can detect which tab has been pressed but I do not know how to pass this on to the customnotebook class to display the relevant page.

I got the closing tabs code from Is there a way to add close buttons to tabs in tkinter.ttk.Notebook? which works well but when the close button is pressed on any page I would also like it to be closed on every page, is this possible?

here is the code I have so far, I have tried to cut it down as much as possible to simplyfy it:

import tkinter as tk
from tkinter import ttk
from ttkthemes import ThemedTk

class LeftTab(ttk.Frame):
    def __init__(self, master, *args, **kwargs):
        super().__init__(master, *args, **kwargs)

        self.grid_rowconfigure(0, weight=1)
        self.grid_columnconfigure(0, weight=1)

        style = ttk.Style(root)
        style.configure('toptab.TNotebook', borderwidth=0)

        notebook = CustomNotebook(self, style='toptab.TNotebook')
        notebook.grid(row=0, column=0, sticky='nswe')

        for server in ('Server 1', 'Server 2', 'Server 3', 'Server 4'):
            frame = tk.Frame(notebook)
            notebook.add(frame, text=server)

# Bryan Oakley
class CustomNotebook(ttk.Notebook):
    """A ttk Notebook with close buttons on each tab"""

    __initialized = False

    def __init__(self, *args, **kwargs):
        if not self.__initialized:
            CustomNotebook.__initialized = True

        kwargs("style") = "CustomNotebook"
        ttk.Notebook.__init__(self, *args, **kwargs)

        self._active = None

        self.bind("<ButtonPress-1>", self.on_close_press, True)
        self.bind("<ButtonRelease-1>", self.on_close_release)

    def on_close_press(self, event):
        """Called when the button is pressed over the close button"""

        element = self.identify(event.x, event.y)

        if "close" in element:
            index = self.index("@%d,%d" % (event.x, event.y))
            self._active = index
            return "break"

    def on_close_release(self, event):
        """Called when the button is released"""

        element =  self.identify(event.x, event.y)
        if "close" not in element:
            # user moved the mouse off of the close button

        index = self.index("@%d,%d" % (event.x, event.y))

        if self._active == index:

        self._active = None

    def __initialize_custom_style(self):
        style = ttk.Style()
        self.images = (
            tk.PhotoImage("img_close", data='''

        style.element_create("close", "image", "img_close", border=8, sticky='')
        style.layout("CustomNotebook", (("CustomNotebook.client", {"sticky": "nswe"})))
        style.layout("CustomNotebook.Tab", (
            ("", {
                "sticky": "nswe",
                "children": (
                    ("CustomNotebook.padding", {
                        "side": "top",
                        "sticky": "nswe",
                        "children": (
                            ("CustomNotebook.label", {"side": "left", "sticky": ''}),
                            ("CustomNotebook.close", {"side": "left", "sticky": ''}),

# Can't add the below to a main class because I loose the images???
def on_tab_selected(event):
    tab_id =

# Theme takes a while to load??
# root = ThemedTk(theme="breeze")
root = tk.Tk()

root.grid_rowconfigure(0, weight=1)
root.grid_columnconfigure(0, weight=1)

# borderwidth does not work
style = ttk.Style(root)
style.configure('lefttab.TNotebook', tabposition='wn', borderwidth=0)

# Adding a style removes the dashed focus line                                   
    (('', {'sticky': 'n', 'children':
        (('Notebook.label', {'side': 'top', 'sticky': ''}))

notebook = ttk.Notebook(root, style='lefttab.TNotebook')
notebook.grid(row=0, column=0, sticky='nswe')

home_frame = ttk.Frame(notebook)

# Need to find darkker icons
img1 = tk.PhotoImage(file='images/icons/24x24/cil-home.png')
img2 = tk.PhotoImage(file='images/icons/24x24/cil-chart-line.png')
img3 = tk.PhotoImage(file='images/icons/24x24/cil-settings.png')

notebook.add(LeftTab(notebook), text='Tab4')
notebook.add(LeftTab(notebook), text='Tab5')

# detect tab change - how to pass this on?
notebook.bind("<<NotebookTabChanged>>", on_tab_selected)

home_label = ttk.Label(home_frame, text='Home Screen Does Not Have Top Tabs')