Group Abstract Group Abstract

Message Boards Message Boards

Why Plot doesn't work when called by ActionMenu?

Posted 3 years ago
POSTED BY: Gianni Mocellin
9 Replies

Dear Rohit,

I have posted a question on WSE right now, 2022.01.06, 08:00.

Kindest regards.

Gianni

POSTED BY: Gianni Mocellin

Dear Rohit,

The chapters 24, 24 and 26 are only in the third edition of the book of Patrick Henry Winston (not in the first and second edition...).

Kindest regards.

Gianni

POSTED BY: Gianni Mocellin

Hi Rohit,

I sent the file "2022.01.05-0500-ActionMenu.nb" also to the Wolfram Support and I am waiting for an answer from them.

As per the interface of the UI for the Expert system, see the attached "Interface du système expert.pdf" file.

As per Lisp code, the Inference engine of the expert system was written in Lisp in 1985.

Roman Maeder from the Swiss Institute of Technology did something quite similar in Mathematica that you can see in his book "The Mathematica Programmer II", Academic Press, 1992, Chapter 2, Logic Programming.

Anyway, I do not want to program again in Lisp because I think that at Wolfram they are showing us the way to go for the future, including using SystemModeler and the Control functions of Mathematica, not forgetting Tracking Control since Mathematica 13.0 (see: Summary of New Features in 13.0 - System Modeling).

As per Jay Sussman, we had a wonderful time at the First Conference on Artificial Intelligence held in Cambridge, UK, I do not remember the year.

Another conference was held latter in the Conference Center of the Twickenham Stadium, UK, a good place to blend artificial intelligence with rugby...

Seeing the picture you attached of the cover of the book of Jay "Structure and Interpretation of Computer Programs" was very emotional for myself, considering the number of hours I spent in trying to understand what he meant in chapter 4, "Metalinguistic Abstraction" and especially in section 4.4 "Logic Programming".

Another very important book preceding the one of Jay was "Lisp", by Patrick Henry Winston, 1981, especially chapter 24 "Symbolic Pattern Matching", chapter 25 "Streams and Delayed Evaluations" and chapter 26 "Rule-Based Expert Systems and Forward Chaining".

So, Rohit, I thank your for your kind suggestions that I will try as soon as I can and compare all that with the solutions provided by the Wolfram Support, if any.

Kindest regards.

Gianni

Attachments:
POSTED BY: Gianni Mocellin

Dear Rohit,

What a pleasure to see your prompt answer and your solution which works perfectly.

I hoped it would also work with a FormFunction as it works with Plot.

Unfortunately I did not succeed in making it work (see here under code).

May be you have a solution also for FormFunction, e.g. with the first Basic Example of the documentation of FormFunction ...

form = FormFunction[{"first" -> "String", "second" -> "Number"}, f];

CreatePalette[
 Grid[{{ActionMenu[
     "Menu logo", {"About" :> 
       NotebookWrite[SelectedNotebook[], 
        Cell["About info", "Text"]]}], 
    ActionMenu[
     "Menu 1", {"Action 1.1" :> 
       NotebookWrite[SelectedNotebook[], Cell["foo", "Text"]], 
      "Action 1.2" :> 
       NotebookWrite[SelectedNotebook[], 
        Cell[ToBoxes[2 + 2], "Output"]], 
      "Action 1.3" :> 
       NotebookWrite[SelectedNotebook[], 
        Cell[ToBoxes[N[Sqrt[2]]], "Output"]], 
      "Action 1.4" :> 
       NotebookWrite[SelectedNotebook[], 
        Cell[{ToBoxes[Plot[Sin[x], {x, 0, 6 Pi}]]}, "Output"]], 
      "Action 1.5" :> 
       NotebookWrite[SelectedNotebook[], 
        Cell[{ToBoxes[form[]]}, "Output"]]}]}}, Frame -> All]]

BTW, I am an old pilot, also qualified as "Mountain glacier pilot", especially in the "Massif du Mont Blanc ", and nothing would be more pleasant for me to have a nice steak at the Café Restaurant de l'aviation.

Do not hesitate to inform me as soon as you have dates and the pleasure of the invitation will be mine.

Kindest regards.

Gianni

POSTED BY: Gianni Mocellin
Posted 3 years ago

Hi Gianni,

I have not been able to figure out why the FormFunction example does not work. This works fine

form = FormFunction[{"first" -> "String", "second" -> "Number"}, f];
NotebookWrite[SelectedNotebook[], Cell[{ToBoxes[form[]]}, "Input"]]

This does not

ActionMenu["Menu", {"Create Form" :> 
   NotebookWrite[SelectedNotebook[], Cell[{ToBoxes[form[]]}, "Input"]]}]

Can you explain what you are trying to accomplish? Why do you need to create a FormFunction from an ActionMenu? Usually FormFunction is used in conjunction with CloudDeploy. If you just intend to use it to create an interface on the desktop where a user can enter values then there may be better ways of doing that.

Thanks for the invite! Hope to take you up on it soon.

POSTED BY: Rohit Namjoshi
Posted 3 years ago

Hi Gianni,

Figured out part of the problem, the Method -> "Queued" option is needed.

ActionMenu["Menu", {"Create Form" :> 
   NotebookWrite[SelectedNotebook[], Cell[{ToBoxes[form[]]}, "Input"]]}, Method -> "Queued"]

However, it fails when wrapped in CreatePalette. I have no idea why. Will ask the question on MSE.

CreatePalette[
 ActionMenu[
  "Menu", {"Create Form" :> 
    NotebookWrite[SelectedNotebook[], Cell[{ToBoxes[Evaluate@form[]]}, "Input"]]}]]
POSTED BY: Rohit Namjoshi
Attachments:
POSTED BY: Gianni Mocellin
Posted 3 years ago
POSTED BY: Rohit Namjoshi
Posted 3 years ago
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard