I have a few notebooks, say nb1, nb2, nb3, nb4. I would like to make a Index with a popupmenu so that when a clicked in each item,labeled nb1, nb2,..., then the respective notebook open.
I've been very cheeky trying to create some code, but of course this far from working well. My code is
DynamicModule[{var = "nb1.nb",
nb1lst = {"nb1.nb", "nb2.nb", "nb3.nb", "nb4.nb"}},
Column[{
PopupMenu[
Dynamic[var], {1 -> "nb1", 2 -> "nb2", 3 -> "nb3", 4 -> "nb4"}],
PaneSelector[{
1 ->
Dynamic@NotebookOpen[
FileNameJoin[{NotebookDirectory[],
TextString[nb1lst[[var]]]}]],
2 ->
Dynamic@NotebookOpen[
FileNameJoin[{NotebookDirectory[],
TextString[nb1lst[[var]]]}]],
3 ->
Dynamic@NotebookOpen[
FileNameJoin[{NotebookDirectory[],
TextString[nb1lst[[var]]]}]],
4 ->
Dynamic@NotebookOpen[
FileNameJoin[{NotebookDirectory[],
TextString[nb1lst[[var]]]}]]},
Dynamic[var]]}]
]
Well, can you help me?
Edit I found an easy answer using Kuba suggestion (Action Menu)
Edit This answer is that is that I was looking for
Module[{nblist = {"nb1.nb", "nb2.nb", "nb3.nb"}},
ActionMenu["Choose a File...",
MapThread[
RuleDelayed, {nblist,
Unevaluated[
NotebookOpen[FileNameJoin[{NotebookDirectory[], #}]]] & /@
nblist}] ]]
var = "nb1.nb"
in the first line tovar = 1
? $\endgroup$ActionMenu
. $\endgroup$