Message Boards Message Boards

Palette code doesn't work in new session?

Posted 2 years ago

I created a palette using an Action menu with the following code:

MakeInfo[] :=
  CreateDocument[
   Column[
    {
     Framed[
      Pane[
       Information[CurrentValue[InputNotebook[], "SelectionData"], 
        "Options"]// Column
       , {390, 190}
       , Scrollbars -> "True"
       , AppearanceElements -> "None"
       , ImageMargins -> {0, 0}
       , FrameMargins -> {0, 0}]],
     Framed[
      Pane[
       Information[CurrentValue[InputNotebook[], "SelectionData"], 
        "Usage"]// Column
       , {390, 190}
       , Scrollbars -> "True"
       , AppearanceElements -> "None"
       , ImageMargins -> {0, 0}
       , FrameMargins -> {0, 0}]]
     }
    , Spacings -> {0, 0}]
   , FontSize -> 13
   , FontFamily -> "Verdana"
   , Editable -> False
   , CellDingbat -> None
   , CellFrame -> 0
   , CellFrameMargins -> 0
   , CellMargins -> 16
   , ShowCellBracket -> False
   , WindowSize -> {540, 540}
   , ImageMargins -> {0, 0}
   , WindowFrame -> "Palette"
   , WindowElements -> {"MagnificationPopUp"}
   , WindowTitle -> 
    ToString[CurrentValue[InputNotebook[], "SelectionData"]] <> 
     " Information"
   ];

ActionMenu[
 "F[x]",
 {"Get Information..." :> MakeInfo[],
  "Full Documenatation..." :> 
   FrontEndExecute[{ 
     FrontEndToken[ FrontEnd`InputNotebook[], 
      "SelectionHelpDialog"]}]
  }]

However, This code fails to work after reloading the Mathematica app. Yes, I an revaluate the code in another notebook to make it work. What am I missing here to make the code stick between sessions? Thanks for your help.

POSTED BY: Andrew Meit
10 Replies
Posted 2 years ago

Thanks for trying to help, means a lot. I don't always need a palette so knowing how to have a folder location thats blessed is important.

POSTED BY: Andrew Meit
Posted 2 years ago

Deleted. A mistake.

POSTED BY: Hans Milton
Posted 2 years ago

Hi Andrew,

To disable that warning take a look at this.

Any reason you did not use CreatePalette? That way it can be installed and always available without having to evaluate the code. Details here.

POSTED BY: Rohit Namjoshi
Posted 2 years ago

Sorry for not responding sooner. Yes! Thanks; learned new powerful code! Solved another problem too.

Now, how do I get the blue button dynamic warning to not trigger when I first open the palette each time? I understand the value of the warning but its not needed for my palette. Thanks!!

POSTED BY: Andrew Meit
Posted 2 years ago

Andrew, its been a few days. Do my suggestion work for you?

POSTED BY: Hans Milton
Posted 2 years ago

You could make the ActionMenu to be inside a DynamicModule. And set the option SaveDefinitions to True.

I have tested the code below with your first version of MakeInfo

DynamicModule[
    {},
    ActionMenu[
        "F[x]",
        {"Get Information..." :> MakeInfo[],
        "Full Documenatation..." :> FrontEndExecute[{
        FrontEndToken[FrontEnd`InputNotebook[],"SelectionHelpDialog"]}]}
    ],
    SaveDefinitions -> True
 ]
POSTED BY: Hans Milton

Hello, I am sure you have checked already, but just in cases: https://reference.wolfram.com/webMathematica/tutorial/TroubleShootingSpecificProblems.html

And this one: https://community.wolfram.com/groups/-/m/t/145890

This should be specific to your version and exact actions and post. Afterwards step by step a right solution will come. Looking forward with best wishes.

POSTED BY: Lariliss Liss
Posted 2 years ago

Thanks for your suggestions. They were somewhat helpful. If I keep the context to just the notebook, the palette still fails to work. Can you or anyone point me to a detailed tutorial on how to create a complex palette whose code will work between Kernal sessions? Thank you.

POSTED BY: Andrew Meit
Posted 2 years ago

Did I present my problem correctly? What is the best tutorial to learn how to fix my problem? Am nearly finished with this palette and this is the one bug I need help with. Thank you.

POSTED BY: Andrew Meit
Posted 2 years ago

Another version...still fails; What am I doing incorrectly to get MakeInfo function work between Sessions? Thanks.

MkPne12[c_, wd_, hd_] :=
  Pane[
   Column[
    Button[#, CopyToClipboard[#], Appearance -> "Frameless", 
       ImageSize -> {350, Automatic}, Alignment -> Left] & /@
     c]
   , {wd, hd}
   , Scrollbars -> "True"
   , AppearanceElements -> "None"
   , ImageMargins -> {0, 0}
   , FrameMargins -> {0, 0}];

MakeInfo[] :=
  (Quiet[
    InitializeValue[sel12, "KernelSession"] = 
     CurrentValue[InputNotebook[], "SelectionData"]];
   Wm12 = 390;
   Hm12 = 190;
   DynamicModule[
    {sel12 = CurrentValue[InputNotebook[], "SelectionData"]},
    Dynamic[sel12];
    CreateDocument[
     Framed[
      Column[
       {MkPne12[Information[sel12, "Options"], Wm12, Hm12],
        MkPne12[TextCases[Information[sel12, "Usage"], "Line"], Wm12, 
         Hm12]}
       ]
      ]
     , FontSize -> 13
     , FontFamily -> "Verdana"
     , Editable -> False
     , CellDingbat -> None
     , CellFrame -> 0
     , CellFrameMargins -> 0
     , CellMargins -> 16
     , ShowCellBracket -> False
     , WindowSize -> {540, 540}
     , ImageMargins -> {0, 0}
     , WindowFrame -> "Palette"
     , WindowElements -> {"MagnificationPopUp"}
     , WindowTitle -> 
      ToString[CurrentValue[InputNotebook[], "SelectionData"]] <> 
       " Information"]
    ]);
POSTED BY: Andrew Meit
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