I think that the Messages notebook might be a magic one. For example,
If I run Notebooks[]
in a new session, I see something like
{NotebookObject["Untitled-1"], NotebookObject["Messages"]}
I can then investigate the messages notebook by
NotebookGet[Notebooks[][[-1]]]
It looks basically normal, except
- it has no
WindowTitle
option, yet it has a title,
- it has the "Delete all Messages" docked cell, although it has no
DockedCells
option.
That is they are both in their default states and so don't show up in the returned NotebookGet[]
expression. (Although in the option inspector, a nonempty expression for DockedCells
does show up, it does not have a checkmark next to it, so it is actually it's default state, which for normal notebooks should be {}
. I'm not sure where it inherits this default from.)
And of course, the property that you noticed,
"closing" the notebook merely sets the option
Visible -> False
, and does not actually close the notebook.
Note that normal notebooks when made invisible do not show up in the Window menu. The message window always has an entry there.
I could not figure out how to replicate these properties.
However, here is a work around.
Store all of your log information in the global variable $Log
, e.g.,
$Log = {1, 2, 3};
And define
CreateLog[vis:(True|False):False, title_String:"LogNotebook"] :=
CreateWindow[DocumentNotebook[Dynamic[Column@$Log]],
Visible -> vis, WindowTitle -> title, Saveable -> False,
NotebookEventActions -> {"WindowClose" :> ($LogNotebook = CreateLog[])}]
Then you can create you log window using
$LogNotebook = CreateLog[True];
and everytime you close it, it is recreated, but in a hidden state. To show it again, you just need to run
SetOptions[$LogNotebook, Visible -> True]
To close it for real, just run
NotebookClose[$LogNotebook]
This can all be made to act and look nicer (but I've spent enough time on this already!)
"CloseBox"
from list ofWindowFrameElements
of the log notebook and add a docked cell with a button that setsVisible->False
when pressed. $\endgroup$