4

I have some code, similar to that from this question (not sure where I modified it from, don't think it was actually that question) to open a simple dynamically refreshing palette showing the currently defined variables.

openVariableTracker[] := 
 CreateWindow[
  PaletteNotebook[
   Dynamic[Grid[
     Prepend[Select[
       With[{expr = ToExpression@#}, {#, Head[expr], expr}] & /@ 
        Names["Global`*"], (#[[2]] =!= Symbol) &], {"Variable", 
       "Type", "Value"}], ItemStyle -> Directive[FontSize -> 28], 
     Spacings -> {2, 2}, Dividers -> "|", Alignment -> Center], 
    UpdateInterval -> 0.1, TrackedSymbols -> {}], 
   WindowTitle -> "Currently Defined Variables"]]

This works fine for my purposes, but often (although not always!) when I close the palette window, a dialog box pops up to ask if I want to "Save Changes" to the notebook.

Is there a way to prevent this? I'm using the code in a lecture explaining the basics of Mathematica, so it would be nice to not be asked when I close the palette.

SPPearce
  • 5,653
  • 2
  • 18
  • 40

1 Answers1

4

Simply add the option Saveable -> False:

 openVariableTracker[] := 
 CreateWindow[
  PaletteNotebook[
   Dynamic[Grid[
     Prepend[Select[
       With[{expr = ToExpression@#}, {#, Head[expr], expr}] & /@ 
        Names["Global`*"], (#[[2]] =!= Symbol) &], {"Variable", 
       "Type", "Value"}], ItemStyle -> Directive[FontSize -> 28], 
     Spacings -> {2, 2}, Dividers -> "|", Alignment -> Center], 
    UpdateInterval -> 0.1, TrackedSymbols -> {}], 
   WindowTitle -> "Currently Defined Variables", Saveable -> False]]
M.R.
  • 31,425
  • 8
  • 90
  • 281
  • I thought there would be something like that, but couldn't find it in the documentation. One of those unhelpful undocumented functions. – SPPearce Feb 14 '17 at 16:06