Message Boards Message Boards

0
|
2472 Views
|
7 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Open notebook in current window

Posted 11 months ago

Is it possible to open a notebook in the current window?

This code opens the notebook in a new window but I want to reuse the window of the current notebook.

NotebookOpen[(*path to notebook*)]
POSTED BY: Azer Bajdzan
7 Replies

So you want the current window opened with book1.nb to be entirely refreshed with contents of book2.nb and be named book2.nb. Seems like feasible but why?

POSTED BY: Jack I Houng

I think there may be confusion about what a notebook window is. The comparison with the documentation is unhelpful because the documentation notebooks have a key characteristic: you can edit them, but they don't save. So it is straightforward to refresh their content. Regular notebooks are not like that: they have a name which links them to the saved file. So what do you want to happen? book1.nb is open with the name book1.nb, linked back to the file book1.nb. When you open book2.nb, do you want the window name to change to book2.nb? I'm guessing you do. But that is a new window. What you are really asking is for a new window to appear in the exact same location as the previous window, and for the previous window to go away. Which maybe you can do programmatically. But what you can't do is just 'replace the contents of the window with a new notebook'. You can replace the contents of the window with the contents of the new notebook, as others have demonstrated, but it will still be book1.nb.

POSTED BY: Gareth Russell
Posted 10 months ago

You understand my question the right way. Or I can describe it by a web browser. You can open a link in a new window/tab or reuse current window in a web browser. If you open new link in current window and want to save it then the file name changes according to the new link name. Now do the same with notebooks in Mathematica instead of webpages in a web browser. Such a simple task and I wonder why they did not include such an option for NotebookOpen like, say, ReuseWindow->True.

POSTED BY: Azer Bajdzan
Posted 10 months ago

Carl's suggestion on NotebookWrite can well be used. Since data can also be a complete notebook. An example:

Save the following notebook to the default directory ($HomeDirectory) and give it the name Example.nb

Then, evaluate this in another notebook:

NotebookWrite[EvaluationNotebook[], Import["Example.nb"]]
POSTED BY: Hans Milton
Posted 10 months ago

I know that all. But this only modifies current opened notebook.

Suppose you have two notebooks in files book1.nb and book2.nb. You have one opened window with book1.nb in it. The task is to open book2.nb in the same window were book1.nb is.

If you use NotebookWrite[EvaluationNotebook[], Import["book2.nb"]] in book1.nb you just modify book1.nb with data of book2.nb.

Opening in the same window should work like it is with documentation (help). When you have help file of Plot function and click on Plot3D the help file of Plot3D is opened in the same window.

Now do the same with book1.nb and book2.nb like it is with help file of Plot and Plot3D.

And of course it must be done without any resaving of notebook.

POSTED BY: Azer Bajdzan

See the Wolfram documentation for NotebookWrite.

POSTED BY: Carl Verdon
Posted 10 months ago

NotebookWrite writes data to the current notebook. It does not open particular notebook in the current window.

POSTED BY: Azer Bajdzan
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract