Skip to main content
edited tags and title
Link
István Zachar
  • 47.2k
  • 20
  • 145
  • 293

A question about code style in ( How to control variables of outer- and inner- ) Manipulate Manipulates?

added 104 characters in body
Source Link
nilo de roock
  • 9.7k
  • 3
  • 35
  • 79

Consider the following ( working ) snippet:

  Manipulate[
   Column[{
    Manipulate[
     vote,
     {vote, {"Yes", "No"}},
     Initialization :> {votes = 0}
    ],
    k,
    Button["TEST", Print[votes]]
   }],
   {k, 1, 5, .5}
  ]

My question concerns programming style and Outer/Inner Manipulate structures. What is the best way to handle code that is executed conditionally based on values in the inner Manipulate, but needs to be processed further in the outer Manipulate? I.e. checking thresholds, maintaining sub-totals, balancing, etc.

To make my question 'answerable' I have translated it in terms of a simplified example: how / where would you maintain a Yes vote counter that is used in the outer manipulate?

UPDATE: The requested pattern would also apply to synchronizing views in data on Tabs on a TabView.

Consider the following ( working ) snippet:

  Manipulate[
   Column[{
    Manipulate[
     vote,
     {vote, {"Yes", "No"}},
     Initialization :> {votes = 0}
    ],
    k,
    Button["TEST", Print[votes]]
   }],
   {k, 1, 5, .5}
  ]

My question concerns programming style and Outer/Inner Manipulate structures. What is the best way to handle code that is executed conditionally based on values in the inner Manipulate, but needs to be processed further in the outer Manipulate? I.e. checking thresholds, maintaining sub-totals, balancing, etc.

To make my question 'answerable' I have translated it in terms of a simplified example: how / where would you maintain a Yes vote counter that is used in the outer manipulate?

Consider the following ( working ) snippet:

  Manipulate[
   Column[{
    Manipulate[
     vote,
     {vote, {"Yes", "No"}},
     Initialization :> {votes = 0}
    ],
    k,
    Button["TEST", Print[votes]]
   }],
   {k, 1, 5, .5}
  ]

My question concerns programming style and Outer/Inner Manipulate structures. What is the best way to handle code that is executed conditionally based on values in the inner Manipulate, but needs to be processed further in the outer Manipulate? I.e. checking thresholds, maintaining sub-totals, balancing, etc.

To make my question 'answerable' I have translated it in terms of a simplified example: how / where would you maintain a Yes vote counter that is used in the outer manipulate?

UPDATE: The requested pattern would also apply to synchronizing views in data on Tabs on a TabView.

Source Link
nilo de roock
  • 9.7k
  • 3
  • 35
  • 79

A question about code style in ( outer- and inner- ) Manipulate

Consider the following ( working ) snippet:

  Manipulate[
   Column[{
    Manipulate[
     vote,
     {vote, {"Yes", "No"}},
     Initialization :> {votes = 0}
    ],
    k,
    Button["TEST", Print[votes]]
   }],
   {k, 1, 5, .5}
  ]

My question concerns programming style and Outer/Inner Manipulate structures. What is the best way to handle code that is executed conditionally based on values in the inner Manipulate, but needs to be processed further in the outer Manipulate? I.e. checking thresholds, maintaining sub-totals, balancing, etc.

To make my question 'answerable' I have translated it in terms of a simplified example: how / where would you maintain a Yes vote counter that is used in the outer manipulate?