8

The built in Palettes of Mathematica are simply .nb files which can be found in the following place:

SystemOpen@FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", 
  "Palettes"}]

I was trying to open anyone of them but it turned out these files opened directly into the Palettes form.

I tried to open them in the Notepad but (as normal) they opened in the expression form.

I tried to copy the Notepad content into expression cell and convert the cell into display from but it did not work and some errors were generated.

Any idea how to open these files in the normal way so that I can explore the codes of these files?

Basheer Algohi
  • 19,917
  • 1
  • 31
  • 78
  • 1
    There is no difference between a palette and a standalone cdf, what was evaluated is lost and what you have needs to be be converted from boxes to expressions. Here is and old topic about that (probably needs updates): How can I recover the source code from cdf file? – Kuba Jun 06 '16 at 05:42
  • 2
    Have you tried selecting Generate Notebook from Palette from the Palettes menu and then converting the generated cell into input form? That works for me. – m_goldberg Jun 06 '16 at 05:47
  • 1
    @m_goldberg In version 10.4.1 I don't have the Generate Notebook from Palette item in the Palettes menu but I do have it in versions 10.0.1 and 8.0.4. With version 8.0.4 your idea seems to work well. It is surprising that in the latest version they removed it... :( – Alexey Popkov Jun 06 '16 at 13:01
  • @AlexeyPopkov. I'm using 10.4.1 and I the item is on my Palettes menu. I'm running on OS X. It is only available when there is a palette loaded. Did you have a palette on your screen? – m_goldberg Jun 06 '16 at 15:18
  • @m_goldberg Yes, here is a screenshot taken with version 10.4.1 on Win7 x64: http://i.stack.imgur.com/CGQnB.png – Alexey Popkov Jun 06 '16 at 15:32
  • @AlexeyPopkov. Another reason not to use Windows :-) – m_goldberg Jun 06 '16 at 15:37
  • @m_goldberg I don't have the Generate Notebook from Palette item in the Palettes menu. I am using 10.4.1 on Windows. Does this item exist in 10.4.1 on other OS? – Basheer Algohi Jun 06 '16 at 15:59
  • @Algohi. I still on the Palettes menu in the Mac version of 10.4.1 – m_goldberg Jun 06 '16 at 16:49
  • @Alexey possibly related?: (54599) – Mr.Wizard Jun 07 '16 at 09:21
  • 1
    @Mr.Wizard Thanks for the link, the workaround suggested by Kuba is very nice! Undoubtedly it is the same issue but now (version 10.4.1) the Generate Notebook from Palette menu item is absent at all. – Alexey Popkov Jun 07 '16 at 10:00

2 Answers2

2

You can Get the palette, then apply MakeExpression in order to convert boxes into the corresponding high-level expression, and then display the result as InputForm. For example:

palette = Get@
   FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", 
     "Palettes", "SlideShow.nb"}];
InputForm @@ MakeExpression[palette, StandardForm]

screenshot

If you aren't satisfied with the default formatting produced by InputForm, I recommend reading this answer of mine.

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
1

Actually I think you can use NotebookGet to get the code of the palettes. With only your notebook and palette opened, Using NotebookGet@Notebooks[][[2]] can get you the expression form, if that's what you need.

But the problem is that this result, just like other outputs of NotebookGet, is full of Cell or CellBox or so, actually still hard to read. But the essential information (especially formats of grids)lies inside them so they're necessary.

Maybe I can give you more detailed and targeted solution to this problem if you can provide me a more specific desired output form.

I hope this answer can help you.

Wjx
  • 9,558
  • 1
  • 34
  • 70