This is an offshoot of how to create a menu as the Documentation Center?...

My aim is to build a menu that functions kind of like the documentation center...a grid of rectangles, each with a dropdown menu, which contains various functions (not documentation). After selecting the function, I'd like the window to be replaced with whatever the function calls. Then, upon closing the new window, the original menu interface returns. I've created an extremely rough piece of code to demonstrate:

DynamicModule[{x = {}}, 
     "Sunset", {"Today" :> (x = CreateDocument@Sunset@Today), 
      "Next Week" :> (x = CreateDocument@Sunset@DatePlus@7)}], 
     "Moon Phase", {"Today" :> (x = 
         CreateDocument@MoonPhase[Today, "Icon"]), 
      "Next Week" :> (x = 
          MoonPhase[DatePlus@7, "Icon"])}]}, {ActionMenu[
     "GeoLocation", {"City" :> (x = CreateDocument@$GeoLocationCity), 
      "Country" :> (x = CreateDocument@$GeoLocationCountry)}], 
     "Map", {"Here" :> (x = CreateDocument@GeoGraphics@Here), 
      "Hawaii" :> (x = 
           Entity["AdministrativeDivision", {"Hawaii", 
             "UnitedStates"}])}], Dynamic@x}}]]  

Which gives the following output:

enter image description here

  1. When I click on an ActionMenu and select one of the functions, a new window opens with the function. How can I have the menu window replaced by the new function, and then when I close the new window, the old menu window returns? I know there is a Deinitialization in the DynamicModule documentation, but I haven't figured that out, and I see that only works once...can it be set to repeat infinitely?

  2. How can I get rid of the {}?

  3. Can I put the entire output in a standalone window/notebook ala CreateDialog?

If there is a better way to do this I'm all ears. I know the output is ugly, I just want to get the basic functionality working first.


1 Answer 1


Here is a first attempt that should get you started:

action[expr_] := Module[{old},
   old = InputNotebook[];
   SetOptions[old, Visible -> False];
   With[{old = old}, 
       Button["Close", {NotebookClose[InputNotebook[]], 
         SetOptions[old, Visible -> True]}]}
     "Sunset", {"Today" :> (action@Sunset@Today), 
      "Next Week" :> (action@Sunset@DatePlus@7)}], 
     "Moon Phase", {"Today" :> (action@MoonPhase[Today, "Icon"]), 
      "Next Week" :> (action@
         MoonPhase[DatePlus@7, "Icon"])}]}, {ActionMenu[
     "GeoLocation", {"City" :> (action@$GeoLocationCity), 
      "Country" :> (action@$GeoLocationCountry)}], 
     "Map", {"Here" :> (action@GeoGraphics@Here), 
      "Hawaii" :> (action@
          Entity["AdministrativeDivision", {"Hawaii", 
            "UnitedStates"}])}]}}, Frame -> True]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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