/* */ .search { float: right; margin-top: -10px; position: relative; display: none; } /* Pop up fancy box for mute and ban */ #popUp { width: 400px; height: 300px; margin-top:4px; } #popUp #header { width: 100%; height: 75px; border-bottom: 1px solid #ccc; background: #ffffff; /* Old browsers */ background: -moz-linear-gradient(top, #ffffff 0%, #f9f9f9 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#f9f9f9)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #ffffff 0%,#f9f9f9 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #ffffff 0%,#f9f9f9 100%); /* Opera 11.10+ */ background: -ms-linear-gradient(top, #ffffff 0%,#f9f9f9 100%); /* IE10+ */ background: linear-gradient(to bottom, #ffffff 0%,#f9f9f9 100%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#f9f9f9',GradientType=0 ); /* IE6-9 */ } #popUp #header span { font-size: 20px; margin: 28px 30px; color: #3E90B9; text-shadow: 0 1px 4px rgba(255, 255, 255, 0.7); display: inline-block; line-height: 1em; } #popUp #body { margin: 30px; margin-top:25px; font-size: 12px; } #popUp #okay-button { margin-top: 30px; background: -webkit-linear-gradient(top, #f6fdff 0%,#b8dcea 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #f6fdff 0%,#b8dcea 100%); /* Opera 11.10+ */ background: -ms-linear-gradient(top, #f6fdff 0%,#b8dcea 100%); /* IE10+ */ background: -moz-linear-gradient(center top , #f6fdff, #b8dcea) repeat scroll 0 0 transparent; background: linear-gradient(top, #f6fdff, #b8dcea) repeat scroll 0 0 transparent; background: -webkit-linear-gradient(top, #f6fdff, #b8dcea) repeat scroll 0 0 transparent; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f6fdff', endColorstr='#b8dcea'); outline: 0; border: 1px solid #85c2e0; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; color: #4990b4; cursor: pointer; display: inline-block; font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bold; line-height: 15px; padding: 5px 15px; position: relative; text-align: center; text-shadow: 0 1px 3px rgba(255, 255, 255, 0.6); -webkit-box-shadow: 0px 1px 4px #eaeaea; -moz-box-shadow: 0px 1px 4px #eaeaea; box-shadow: 0px 1px 4px #eaeaea; vertical-align: center; text-decoration: none; } #verificationDialog { margin: 0; padding: 0; } #validate-header { width: 100%; height: 70px; border-bottom: 1px solid #E5E5E5; background-color: #F8F8F8; border-radius: 7px 7px 0 0; } #validate-header h1 { display: inline-block; line-height: 1em; font-family: Helvetica; margin: 0; padding: 26px 25px; color: #5EA1C3; font-size: 23px; font-weight: normal; text-shadow: 0px 2px 2px #DDD; } #validate-body { padding: 15px 25px; color: #333; } #validate-body span { display: block; font-family: Arial; font-size: 12px; color: #555; padding-bottom: 15px; } .resend { color: #777; font-family: Arial; font-size: 13px; } .resend:hover { color: #3E90B9; } #joinCommunityDialog { width: 650px; height: 445px; } #header { width: 100%; height: 75px; border-bottom: 1px solid #ccc; border-radius: 7px 7px 0 0; background: #ffffff; /* Old browsers */ background: -moz-linear-gradient(top, #ffffff 0%, #f9f9f9 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#f9f9f9)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #ffffff 0%,#f9f9f9 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #ffffff 0%,#f9f9f9 100%); /* Opera 11.10+ */ background: -ms-linear-gradient(top, #ffffff 0%,#f9f9f9 100%); /* IE10+ */ background: linear-gradient(to bottom, #ffffff 0%,#f9f9f9 100%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#f9f9f9',GradientType=0 ); /* IE6-9 */ } #header span { font-size: 23px; font-family: Helvetica; margin: 28px 29px; color: #5EA1C3; text-shadow: 0 2px 2px #DDD; display: inline-block; line-height: 1em; } #agreement ol li { font-size: 12px; display: inline-block; padding-right: 5px; color: #73bbdd; min-width: 125px; } .tou-tabs { display: flex; margin: 15px 0px 4px 30px; } .tou-tabs li { margin-right: 10px } ol li span { color: #7c7c7c; font-size: 13px; font-family: Arial; } label { color: #666666; } .tab-text { position: absolute; margin-top: 11px; } .tab-num-box { color: #7c7c7c; background-color: #e2e2e2; width: 41px; height: 36px; text-align: center; margin-right: 8px; display:block; float:left; } .tab-num-text { padding: 0px; margin-left: 15px; margin-top: 11px; font-family: 'Museo500'; font-size: 19px; display:block; float:left; } .finished { border: 1px solid #d7edf5; margin-bottom: -1px; background-color: #f8f8f8; } .finished .tab-num-box { color: white; font-family: 'Museo300'; background-color: #c5e3f2; } .finished .tab-num-text { color: #5A9ABA; } .finished .tab-text { font-family: 'Arial'; font-weight: bold; color: #c4e2f2; font-size: 13px; } .active .tab-num-box { background-color: #73bbdd; width: 41px; height: 41px; box-shadow: 0px 0px 5px (0, 0, 0 0.35); } .active .tab-num-text { color: white; margin-top: 13px; margin-left: 16px; } .active .tab-text { font-family: Arial; font-weight: bold; color: #5A9ABA; margin-top: 13px; } .wolframIdTab { width: 275px; } .wolframIdTab .tab-text { padding: 0px; } .acceptTouTab { border: 1px solid #b7dbed; border-bottom: none; opacity: 1; background-color: #f7fdff; width: 291px; height: 41px; margin-bottom: -5px; } .panel { background-color: #f7fdff; border: 1px solid #b7dbed; margin: 0px 30px; } .panel .label { display: block; font-family: Arial; font-size: 12px; color: #555; margin: 5px 15px; } .sub-panel { border-top: 1px solid #B7DBED; background: #fff; padding: 20px; padding-left: 25px; } .sub-panel a { padding: 0px 15px; text-decoration: none; font-size: 12px; color: #3187a7; } .sub-panel a:hover { color: #0a6089; } input[type="submit"] { background: -moz-linear-gradient(center top , #f6fdff, #b8dcea) repeat scroll 0 0 transparent; background: linear-gradient(top, #f6fdff, #b8dcea) repeat scroll 0 0 transparent; background: -webkit-linear-gradient(top, #f6fdff, #b8dcea) repeat scroll 0 0 transparent; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f6fdff', endColorstr='#b8dcea'); outline: 0; border: 1px solid #85c2e0; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; color: #4990b4; cursor: pointer; display: inline-block; font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bold; line-height: 15px; padding: 5px 15px; position: relative; text-align: center; text-shadow: 0 1px 3px rgba(255, 255, 255, 0.6); -webkit-box-shadow: 0px 1px 4px #eaeaea; -moz-box-shadow: 0px 1px 4px #eaeaea; box-shadow: 0px 1px 4px #eaeaea; vertical-align: center; text-decoration: none; } input[type="submit"]:hover { background: -moz-linear-gradient(center top , #f6fdff, #90cae1) repeat scroll 0 0 transparent; background: linear-gradient(top, #f6fdff, #90cae1) repeat scroll 0 0 transparent; background: -webkit-linear-gradient(top, #f6fdff, #90cae1) repeat scroll 0 0 transparent; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f6fdff', endColorstr='#90cae1'); border: 1px solid #85c2e0; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; color: #3e90b9; cursor: pointer; display: inline-block; font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bold; line-height: 15px; padding: 5px 15px; position: relative; text-align: center; text-shadow: 0 1px 4px rgba(255, 255, 255, 0.7); vertical-align: center; text-decoration: none; } .cancel-button { background: -moz-linear-gradient(center top , #f6fdff, #b8dcea) repeat scroll 0 0 transparent; background: linear-gradient(top, #f6fdff, #b8dcea) repeat scroll 0 0 transparent; background: -webkit-linear-gradient(top, #f6fdff, #b8dcea) repeat scroll 0 0 transparent; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f6fdff', endColorstr='#b8dcea'); outline: 0; border: 1px solid #85c2e0; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; color: #4990b4; cursor: pointer; display: inline-block; font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bold; line-height: 15px; padding: 5px 15px; position: relative; text-align: center; text-shadow: 0 1px 3px rgba(255, 255, 255, 0.6); -webkit-box-shadow: 0px 1px 4px #eaeaea; -moz-box-shadow: 0px 1px 4px #eaeaea; box-shadow: 0px 1px 4px #eaeaea; vertical-align: center; text-decoration: none; } .cancel-button:hover { background: -moz-linear-gradient(center top , #f6fdff, #90cae1) repeat scroll 0 0 transparent; background: linear-gradient(top, #f6fdff, #90cae1) repeat scroll 0 0 transparent; background: -webkit-linear-gradient(top, #f6fdff, #90cae1) repeat scroll 0 0 transparent; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f6fdff', endColorstr='#90cae1'); border: 1px solid #85c2e0; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; color: #3e90b9; cursor: pointer; display: inline-block; font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bold; line-height: 15px; padding: 5px 15px; position: relative; text-align: center; text-shadow: 0 1px 4px rgba(255, 255, 255, 0.7); vertical-align: center; text-decoration: none; } #join-text { padding: 25px; color: #555; font-size: 13px; font-family: 'Arial'; height: 160px; line-height: 18px; color: #777; } #join-text a { text-decoration: none; color: #3187a7; } #join-text a:hover { text-decoration: none; color: #0a6089; } #join-text span { display: block; padding-bottom: 15px; } #confirm-cancel-text { padding: 25px; color: #777; font-size: 13px; line-height: 18px; font-family: 'Arial'; height: 160px; } #confirm-cancel-text h1 { font-family: Museo500; font-size: 17px; color: #146F9D; margin: 0px; font-weight: normal; } #confirm-cancel-text span { display: block; padding-bottom: 5px; } #cancel-reg { cursor: pointer; }

Message Boards Message Boards

Answer (Unmark) Mark as an Answer
.root-post .like-component { align-items: center; } .root-post .like-button { margin-left: 10px; } WOLFRAM COMMUNITY 0 | 292 Views | 3 Replies | 0 Total Likes View groups... Follow this post Share Share this post: GROUPS: Graphics and Visualization Wolfram Language Packages

Package function doesn't plot math function when given as input

L P L P L P Posted 19 days ago .root-post .like-component { align-items: center; } .root-post .like-button { margin-left: 0; }

Hi everybody! I'm new to Mathematica and I'm trying to learn to write some basic code to create a DialogInput in which the user writes the function to plot.

I'd like to understand how packages work, so I'm trying to move the function GuessTheFunctionGUI in the package, leaving just the call of the package function in the notebook.

When I leave the GuessTheFunctionGUI in the notebook everything works fine, but at the moment when I run the code and write the function in the InputField then the Plot is not dynamically updated (to tell the truth, nothing is plotted).

Any tips on what I'm messing? My idea is that the Private scope of the function doesn't allow updating dynamically the value of the math function in the plot.

Notebook.nb

Get["Package.wl"];

ButtonBox["Start", Appearance -> Automatic, 
  ButtonFunction :> 
   FrontEndExecute[FrontEndToken["EvaluateNotebook"]], 
  Evaluator -> Automatic, Method -> "Preemptive"] // DisplayForm
GuessTheFunctionGUI[];

Package.wl

BeginPackage["Package`"];

GuessTheFunctionGUI::usage = "GuessTheFunctionGUI[]";

Begin["`Private`"];
SetDirectory[NotebookDirectory[]];

GuessTheFunctionGUI[] := DynamicModule[{func = ""},
  DialogInput[
  Column[{
    InputField[Dynamic[func], String, FieldHint -> "Insert the function here"],
    Dynamic@Plot[ToExpression[func], {x, -10, 10}, PlotStyle -> Blue, 
      AxesLabel -> {"x", "y"}, PlotLabel -> "Function plot", ImageSize -> Medium]
    }],
    WindowTitle -> "Interactive Plot", WindowSize -> {500, 500}, 
    WindowMargins -> {{Automatic, 0}, {0, Automatic}}, 
    WindowElements -> {"VerticalScrollBar", "HorizontalScrollBar", "StatusArea"}
  ]]

End[];
EndPackage[];

I don't know if this is relevant too, but the version of Mathematica that I'm using is the following:

$Version
"14.0.0 for Microsoft Windows (64-bit) (December 13, 2023)"
POSTED BY: L P 3 Replies Sort By: .root-post .like-component { align-items: center; } .root-post .like-button { margin-left: 0; } 0 T Vine T Vine T Vine Posted 19 days ago

Hello! I hate to say this, but for some reason your code works for me, so I'm not sure whether it's because you're using a different version of Mathematica? One thing I did note was that the 'NoteBookDirectory[]' function didn't work for me, so I changed it so that it was set to the actual path of your main file. You could otherwise (I believe) just save to the same directory. If you're not getting an actual error though, that's pretty odd. It might just be worth restarting your PC/Mathematica.

To summate quicker, maybe put in the direct file path to your main file into the directory function, and try that. It seems to suggest something wrong parsing the actual package. Hopefully this helps though :)

POSTED BY: T Vine .root-post .like-component { align-items: center; } .root-post .like-button { margin-left: 0; } 0 L P L P L P Posted 18 days ago

Thanks for your answer! I could put in the direct file path to my main file into the directory function, but I'm trying to develop something that can be used as a standalone software. The idea is that every user that clones my repository can just click the Start button and play with it without having to worry about changing anything.

For the

You could otherwise (I believe) just save to the same directory.

part, I'm already working on a repo that contains both .nb and .wl in the same folder, so I guess that is not the case unfortunately.

I believe that the code that I wrote so far isn't exactly fit for this purpose. Any idea on how I could change it?

P.S. are you on Linux? Because a colleague of mine stated that somehow this code works on his computer.

POSTED BY: L P .root-post .like-component { align-items: center; } .root-post .like-button { margin-left: 0; } 0 T Vine T Vine T Vine Posted 18 days ago

Hey, no problem sorry that won't work! I am on Linux (at least the Raspberry Pi distro), which is odd. If you're planning it as something anyone can just fork, perhaps it would be a good idea to just leave out the NoteBookDirectory function, and instead create a subfolder in your repository where packages are? For example: SRC- - Main.wl -Notebook.nb -PACKAGES - Package.wl And then use <<"PACKAGES/Package.wl" (or Needs[]) in your notebook file? That should hopefully enable it to work from scratch, as you said I hope. Although I'm not sure whether that should fix the original problem, I'll try and take a deeper look into it.

POSTED BY: T Vine
Reply to this discussion in reply to Community posts can be styled and formatted using the Markdown syntax. Tag limit exceeded Note: Only the first five people you tag will receive an email notification; the other tagged names will appear as links to their profiles. Reply Preview Attachments Remove or Discard

Group Abstract Group Abstract

Be respectful. Review our Community Guidelines to understand your role and responsibilities. Community Terms of Use Feedback © 2024 Wolfram. All rights reserved.