Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: GUIKit

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50789] Re: [mg50714] GUIKit
  • From: Jeff Adams <jeffa at wolfram.com>
  • Date: Tue, 21 Sep 2004 03:49:06 -0400 (EDT)
  • References: <200409180948.FAA00462@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On Sep 18, 2004, at 4:48 AM, Bill Collins wrote:

> I have been playing with the new GUIKit.  I have attempted to modify 
> one
> of the examples (RealTimePlotting) by inserting a second slider with an
> additional parameter conrolling the equation.  After trying several
> combinations I cannot get it to work.  Do I use two Script commands and
> separate sliderFunc definitions for  each parameter? Any hint would be
> helpful.
>
> Bill Collins
> wccollins at starband.net

Hi Bill,

Here is a simple extended version of that example with three sliders
controlling three different parameters. This is just one way
you could design something that should scale for an arbitrary number of 
sliders
or other control widgets.

Thanks
Jeff Adams
Wolfram Research

-----

GUIRunModal[
  Widget["Panel", {
    {Widget["Label", {"text" -> "a:"}],
     Widget["Slider", {BindEvent["change", Script[updatePlot[]; ]]}, 
Name -> "aSlider",
       WidgetLayout -> {"Stretching" -> {Maximize, False}}]},
    {Widget["Label", {"text" -> "b:"}],
     Widget["Slider", {"value" -> 3, "minimum" -> 1, "maximum" -> 15, 
BindEvent["change",
         Script[updatePlot[]; ]]}, Name -> "bSlider", WidgetLayout -> 
{"Stretching" -> {Maximize, False}}]},
    {Widget["Label", {"text" -> "c:"}],
     Widget["Slider", {"value" -> 10, "minimum" -> 1, "maximum" -> 15,
        BindEvent["change", Script[updatePlot[]; ]]}, Name -> "cSlider",
       WidgetLayout -> {"Stretching" -> {Maximize, False}}]},
    Widget["MathPanel",
      { "preferredSize" -> Widget["Dimension", {"width" -> 288, "height" 
-> 288}]}, Name -> "canvas",
      WidgetLayout -> {"Stretching" -> {True, Maximize}}], 
Widget["TextArea",
      {"text" -> "Plot[Sin[b/10 x]^a,{x, 0, c Pi}]", "rows" -> 3}, Name 
-> "plotStringText"],

    "preferredSize" -> Widget["Dimension", {"width" -> 288, "height" -> 
340}],
    BindEvent["componentResized", Script[updatePlot[]; ]],
    BindEvent["endModal", Script[expr]],

    Script[
     updatePlot[] := Block[{a, b, c, $DisplayFunction = Identity},
         a = Round[ToExpression[PropertyValue[{"aSlider", "value"}]]/10];
         b = ToExpression[PropertyValue[{"bSlider", "value"}]];
         c = ToExpression[PropertyValue[{"cSlider", "value"}]];
         expr = ToExpression[PropertyValue[{"plotStringText", "text"}]]; 
expr = Show[expr, PlotRange -> All];
         SetPropertyValue[{"canvas", "mathCommand"}, ToString[expr, 
InputForm]]]; updatePlot[];
     ]
    }]
   ]


  • References:
    • GUIKit
      • From: "Bill Collins" <wccollins@starband.net>
  • Prev by Date: Re: Re: How to simplify to a result that is real
  • Next by Date: Re: Re: Forcing a Derivative
  • Previous by thread: GUIKit
  • Next by thread: Syntax Questions