4
$\begingroup$

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.

$\endgroup$
4
$\begingroup$

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]]
$\endgroup$
  • $\begingroup$ I thought there would be something like that, but couldn't find it in the documentation. One of those unhelpful undocumented functions. $\endgroup$ – KraZug Feb 14 '17 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.