0
$\begingroup$

I am trying to give information to the user of the code via popup windows with CreateDialog. It is working fine when I use .nb file, the windows has the information and the plots and after 5seconds pause they close. But when I save .nd file as EnterPrise CDF it is not working, no windows there for I don't know if they would close. I don't know why? Any ideas. Here is a "toy code" what I am trying to do.

Get[FileNameJoin[{NotebookDirectory[EvaluationNotebook[]], 
"Trialpack3.wl"}]]
Panel@Framed[DynamicModule[{Heval = 1, Leval = 1},
 Grid[{
 {Style["                              "], SpanFromLeft},
 {Style["                Inputs ", 16, Blue], SpanFromLeft},
 {Style["                              "], SpanFromLeft},
 {Row[{Style["H, (m) ", 12, Blue, Editable -> False], 
    InputField[Dynamic[Heval], FieldSize -> {10, 1.5}]}, 
   Spacer[70]], 
  Row[{Style["L, (m) ", 12, Blue, Editable -> False], 
    InputField[Dynamic[Leval], FieldSize -> {10, 1.5}]}, 
   Spacer[45]]},
 {Grid[{ {Style["  ", 12, Black, Editable -> False]}, {Button[
      Style["Compute", Green, Bold],
      Res = Trialpack3`MainFunc[Heval, Leval];, 
      Method -> "Queued"]}}], SpanFromLeft},
 {Style["", 12, Blue], Style["", 12, Blue]}
 }],
 Initialization :> (
 Get[FileNameJoin[{NotebookDirectory[EvaluationNotebook[]], 
    "Trialpack3.wl"}]])
  ], Background -> Lighter[Gray, .6]]

And the package file is

BeginPackage["Trialpack3`"];
MainFunc::usage=" ";
Begin["`Private`"];
$MaxExtraPrecision=\[Infinity];
MainFunc[H_,L_]:=Module[{},
Quiet[LaunchKernels[]];
DimenScales=CreateDialog[Row[{Style["        Variables   \n",18,Black],
Row[{Style["   \n       H= 
 ",14,Blue],Style[ToString[N[H],TraditionalForm],14,Black],Style["  \n          
",14,Red]}],
Row[{Style["   \n       L= 
",14,Blue],Style[ToString[N[L],TraditionalForm],14,Black],Style["  \n          
",14,Red]}]
 }]];

Tplot3DINI=Plot3D[Sin[x*z],{x,0,L},{z,0,H},ImageSize->Medium];


 T3DplotDialog3D=CreateDialog[Grid[{{Row[{Style["         FIELD 
 \n",15,Red]
 }]},{Tplot3DINI}}],Background->White];



  Pause[5];
  NotebookClose[DimenScales];
  NotebookClose[T3DplotDialog3D];

  ];

  SetAttributes[MainFunc,{HoldAll}];
  End[];
  EndPackage[];

Because I could not find a way to attach documents in here I posted the same question in mathematica community where I attached the documents. http://community.wolfram.com/groups/-/m/t/1396848?p_p_auth=X3vsM61w

$\endgroup$
6
  • $\begingroup$ It is not the first time I will ask you to prepare a minimal example. Is everything above needed to show an issue with a dialog window which does not appear? Is the code of the package related to the problem? Have you tried to remove loading external package from possible reasons? etc etc. It is in your interest to prepare as short and clear example as possible. $\endgroup$
    – Kuba
    Commented Aug 3, 2018 at 11:57
  • $\begingroup$ Can you tell me what is too complicated? I don't know if the package related to the problem or not. I use the package while using .nd format. Also, I need the package, I can't put my code inside the GUI. As I said this is not my real code. Also, if I compare my question and some other in here, mine is much simpler. I can remove one of the plots from the package but the rest is there to mimic my real code. $\endgroup$
    – Erdem
    Commented Aug 3, 2018 at 12:04
  • $\begingroup$ Frankly, I don't remember the status of creating dialog windows in various cdfs types. First thing I'd do is to deploy a specific .cdf type containing e.g. Button["test", MessageDialog["test"], Method -> "Queued"] to make sure. $\endgroup$
    – Kuba
    Commented Aug 3, 2018 at 12:07
  • $\begingroup$ That is working, I feel like there is problem with loading the package, it is not the popup windows. I simply run the code as .nb and right after that I do the CDF PreReview from File and nothing. $\endgroup$
    – Erdem
    Commented Aug 3, 2018 at 12:14
  • $\begingroup$ Deploying a .cdf is not the same as clicking "cdf preview", how is it supposed to interprete NotebookDirectory[] then? Is deployed .cdf next to the package file? $\endgroup$
    – Kuba
    Commented Aug 3, 2018 at 12:17

1 Answer 1

1
$\begingroup$

As I mentioned in the comments section for some reason even after deploying the cdf (not just prereview) the package file was not loading. I found a way around it to create a button that will load the package. I am aware that this is not an elegant solution but it works. If there is anybody who can find why it was not working in an original post.

Button["test", 
Get[FileNameJoin[{NotebookDirectory[EvaluationNotebook[]], 
"Trialpack3.wl"}]], Method -> "Queued"]
$\endgroup$

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.