Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2009

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

Search the Archive

Dependent dynamic controls

  • To: mathgroup at
  • Subject: [mg100367] Dependent dynamic controls
  • From: replicatorzed at
  • Date: Tue, 2 Jun 2009 06:42:01 -0400 (EDT)

Dear Group,

I have a set of dynamic controls that should control a complicated
program (omitted here). The following code works partially:
initialization is not performed correctly, but afterwards everything
runs as expected:

aSet = {"a1", "a2", "a3"};
bSet = {"b1", "b2", "b3"};

Module[{sw = True, a, b, c, n, assign},
 assign[switch_, x_] :=
  If[switch, a = x; c = f@x; n = Position[aSet, x][[1, 1]];, b = x;
   c = g@x; n = Position[bSet, x][[1, 1]]];
 (* Initialize *)
 assign[sw, First@If[sw, aSet, bSet]];
     (* Output *)
     Column@{sw, If[sw, a, b], c, n},
     (* Controls *)
        RadioButton[Dynamic[sw, (sw = #; assign[#, First@aSet]) &],
        PopupMenu[Dynamic[a, assign[sw, #] &], aSet, Enabled -> sw]},
        RadioButton[Dynamic[sw, (sw = #; assign[#, First@bSet]) &],
        PopupMenu[Dynamic[b, assign[sw, #] &], bSet, Enabled -> ! sw]}

The problem is after running the code a and b are not assigned their
correct values, while after startup switching between a and b by the
radiobutton, and switching values for a and b via the popupmenus work
The code above is almost identical to the method used by David Park
(at least three examples were posted:

Although with the introduction of the switch variable 'sw',
dependencies do not initialize normally. Any idea how to overcome

Istvan Zachar

  • Prev by Date: Re: Perpendicular lines do not appear perpendicular
  • Next by Date: Re: The standard deviation of Three fitting parameters is bigger than
  • Previous by thread: Re: difference between HeavisidePi and UnitBox
  • Next by thread: Re: Dependent dynamic controls