Message Boards Message Boards

2 Replies
1 Total Likes
View groups...
Share this post:

Problem with TogglerBar in a Module

Hello Community, I have the following problem. From a list of words I want to choose some and process the chosen words later on. My attempt is as follows (I´m not very experienced with such problems, especially with Dynamic, so maybe there is a much simpler solution):

choose[words_] := DynamicModule[{x, temp = words}, {TogglerBar[Dynamic@x, temp]; Dynamic@x} .... further processing of x .... ]

I experimented with Dynamics (as you see) but with no effort. I want to get a list of chosen words. Does anyone have a hint for me - solution would be great ;-)

Greetings from Germany


POSTED BY: Michael Gamer
2 Replies
Posted 10 years ago

Hello David,

thank you for the answer this is helpful, but not the whole solution. The problem is, that I want to process the output (i.e. x) after having chosen words via TogglerBar, the structure of the module (or DynamicModule?) ist somewhat like:

choosewords[words : {_String ..}] := Module[{list = words, out = {}},
  out = chooseWords[list]; (* Here is your function*)
  out = Take[out, 1]; (* here some more code, 
  just an example....*)


If I put the semicolon after the function, I get no output. I´m not very familiar, as you see, with user-interfaces, this is my first attempt ;-)

Greetings Mike

POSTED BY: Updating Name

Try starting from the following. It is based on your trial. Compare it with yours to see the modificaitons that were needed to make it work. I hope this helps... --David

chooseWords[words : {_String ..}] :=
 DynamicModule[{x = {}, temp = words},
  {TogglerBar[Dynamic@x, temp], 

Make use of it, for example, like the following

chooseWords[{"aword", "bword", "cword", "dword"}]

I assumed you wanted to be restricted to Strings, but that is not necessary in order to make it work.

POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract