Skip to main content
Commonmark migration
Source Link

###Manipulate version.

Manipulate version.

Manipulate[
 Row@string
 ,
 Column[{Dynamic[pop /@ Range[n] // Row, TrackedSymbols :> {n}], 
   SetterBar[
    Dynamic[x, 
     If[# === "+", n++; string = Join[string, {"a"}], n--; 
       string = Most@string] &], {"+", "-"}]}]
 ,
 
 {x, None},
 {n, None},
 {string, None}
 ,
 Initialization :> (
   pop[i_] := 
    With[{j = i}, 
     PopupMenu[Dynamic[string[[j]]], CharacterRange["a", "z"]]];
   string = ConstantArray["a", 4];
   n = 4;
   
   )
 ]

enter image description here

DynamicModule version.

###DynamicModule version. LetLet me not use Manipulate, it is more handy with DynamicModule in more complex cases:

DynamicModule[{ pop, x, n = 4, string = ConstantArray["a", 4] },

 pop[i_] := With[{j = i}, 
   PopupMenu[Dynamic[string[[j]]], CharacterRange["a", "z"]]
   ];
 
 Panel@Column[{
    Dynamic[pop /@ Range[n] // Row, TrackedSymbols :> {n}],
    SetterBar[
     Dynamic[x, If[# === "+", n++; string = Join[string, {"a"}], 
                              n--; string = Most@string
        ] &], {"+", "-"}],
    Dynamic@Row@string
    }
   ]
 ]

enter image description here

###Manipulate version.

Manipulate[
 Row@string
 ,
 Column[{Dynamic[pop /@ Range[n] // Row, TrackedSymbols :> {n}], 
   SetterBar[
    Dynamic[x, 
     If[# === "+", n++; string = Join[string, {"a"}], n--; 
       string = Most@string] &], {"+", "-"}]}]
 ,
 
 {x, None},
 {n, None},
 {string, None}
 ,
 Initialization :> (
   pop[i_] := 
    With[{j = i}, 
     PopupMenu[Dynamic[string[[j]]], CharacterRange["a", "z"]]];
   string = ConstantArray["a", 4];
   n = 4;
   
   )
 ]

enter image description here

###DynamicModule version. Let me not use Manipulate, it is more handy with DynamicModule in more complex cases:

DynamicModule[{ pop, x, n = 4, string = ConstantArray["a", 4] },

 pop[i_] := With[{j = i}, 
   PopupMenu[Dynamic[string[[j]]], CharacterRange["a", "z"]]
   ];
 
 Panel@Column[{
    Dynamic[pop /@ Range[n] // Row, TrackedSymbols :> {n}],
    SetterBar[
     Dynamic[x, If[# === "+", n++; string = Join[string, {"a"}], 
                              n--; string = Most@string
        ] &], {"+", "-"}],
    Dynamic@Row@string
    }
   ]
 ]

enter image description here

Manipulate version.

Manipulate[
 Row@string
 ,
 Column[{Dynamic[pop /@ Range[n] // Row, TrackedSymbols :> {n}], 
   SetterBar[
    Dynamic[x, 
     If[# === "+", n++; string = Join[string, {"a"}], n--; 
       string = Most@string] &], {"+", "-"}]}]
 ,
 
 {x, None},
 {n, None},
 {string, None}
 ,
 Initialization :> (
   pop[i_] := 
    With[{j = i}, 
     PopupMenu[Dynamic[string[[j]]], CharacterRange["a", "z"]]];
   string = ConstantArray["a", 4];
   n = 4;
   
   )
 ]

enter image description here

DynamicModule version.

Let me not use Manipulate, it is more handy with DynamicModule in more complex cases:

DynamicModule[{ pop, x, n = 4, string = ConstantArray["a", 4] },

 pop[i_] := With[{j = i}, 
   PopupMenu[Dynamic[string[[j]]], CharacterRange["a", "z"]]
   ];
 
 Panel@Column[{
    Dynamic[pop /@ Range[n] // Row, TrackedSymbols :> {n}],
    SetterBar[
     Dynamic[x, If[# === "+", n++; string = Join[string, {"a"}], 
                              n--; string = Most@string
        ] &], {"+", "-"}],
    Dynamic@Row@string
    }
   ]
 ]

enter image description here

added 706 characters in body
Source Link
Kuba
  • 137.7k
  • 13
  • 289
  • 751

Let###Manipulate version.

Manipulate[
 Row@string
 ,
 Column[{Dynamic[pop /@ Range[n] // Row, TrackedSymbols :> {n}], 
   SetterBar[
    Dynamic[x, 
     If[# === "+", n++; string = Join[string, {"a"}], n--; 
       string = Most@string] &], {"+", "-"}]}]
 ,
 
 {x, None},
 {n, None},
 {string, None}
 ,
 Initialization :> (
   pop[i_] := 
    With[{j = i}, 
     PopupMenu[Dynamic[string[[j]]], CharacterRange["a", "z"]]];
   string = ConstantArray["a", 4];
   n = 4;
   
   )
 ]

enter image description here

###DynamicModule version. Let me not use Manipulate, it is more handy with DynamicModule in more complex cases:

DynamicModule[{ pop, x, n = 4, string = ConstantArray["a", 4] },

 pop[i_] := With[{j = i}, 
   PopupMenu[Dynamic[string[[j]]], CharacterRange["a", "z"]]
   ];
 
 Panel@Column[{
    Dynamic[pop /@ Range[n] // Row, TrackedSymbols :> {n}],
    SetterBar[
     Dynamic[x, If[# === "+", n++; string = Join[string, {"a"}], 
                              n--; string = Most@string
        ] &], {"+", "-"}],
    Dynamic@Row@string
    }
   ]
 ]

enter image description here

Let me not use Manipulate, it is more handy with DynamicModule in more complex cases:

DynamicModule[{ pop, x, n = 4, string = ConstantArray["a", 4] },

 pop[i_] := With[{j = i}, 
   PopupMenu[Dynamic[string[[j]]], CharacterRange["a", "z"]]
   ];
 
 Panel@Column[{
    Dynamic[pop /@ Range[n] // Row, TrackedSymbols :> {n}],
    SetterBar[
     Dynamic[x, If[# === "+", n++; string = Join[string, {"a"}], 
                              n--; string = Most@string
        ] &], {"+", "-"}],
    Dynamic@Row@string
    }
   ]
 ]

enter image description here

###Manipulate version.

Manipulate[
 Row@string
 ,
 Column[{Dynamic[pop /@ Range[n] // Row, TrackedSymbols :> {n}], 
   SetterBar[
    Dynamic[x, 
     If[# === "+", n++; string = Join[string, {"a"}], n--; 
       string = Most@string] &], {"+", "-"}]}]
 ,
 
 {x, None},
 {n, None},
 {string, None}
 ,
 Initialization :> (
   pop[i_] := 
    With[{j = i}, 
     PopupMenu[Dynamic[string[[j]]], CharacterRange["a", "z"]]];
   string = ConstantArray["a", 4];
   n = 4;
   
   )
 ]

enter image description here

###DynamicModule version. Let me not use Manipulate, it is more handy with DynamicModule in more complex cases:

DynamicModule[{ pop, x, n = 4, string = ConstantArray["a", 4] },

 pop[i_] := With[{j = i}, 
   PopupMenu[Dynamic[string[[j]]], CharacterRange["a", "z"]]
   ];
 
 Panel@Column[{
    Dynamic[pop /@ Range[n] // Row, TrackedSymbols :> {n}],
    SetterBar[
     Dynamic[x, If[# === "+", n++; string = Join[string, {"a"}], 
                              n--; string = Most@string
        ] &], {"+", "-"}],
    Dynamic@Row@string
    }
   ]
 ]

enter image description here

Source Link
Kuba
  • 137.7k
  • 13
  • 289
  • 751

Let me not use Manipulate, it is more handy with DynamicModule in more complex cases:

DynamicModule[{ pop, x, n = 4, string = ConstantArray["a", 4] },

 pop[i_] := With[{j = i}, 
   PopupMenu[Dynamic[string[[j]]], CharacterRange["a", "z"]]
   ];
 
 Panel@Column[{
    Dynamic[pop /@ Range[n] // Row, TrackedSymbols :> {n}],
    SetterBar[
     Dynamic[x, If[# === "+", n++; string = Join[string, {"a"}], 
                              n--; string = Most@string
        ] &], {"+", "-"}],
    Dynamic@Row@string
    }
   ]
 ]

enter image description here