本文介绍了可以在数学中使用TogglerBar作为多个复选框吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以使用 TogglerBar而不是2复选框来显示或不显示不同的形状。

Would it be possible to have a TogglerBar instead of the 2 Check Box to show or not the different Shapes.

使用Green&红色写在每个按钮的TogglerBar?

With Green & Red written in each Button of the TogglerBar ?

Manipulate[
Graphics[{If[thePink, {Pink, Disk[{5, 5}, 3]}], 
If[theGreen, {Green, Disk[{15, 2}, 1]}]}, 
PlotRange -> {{0, 20}, {0, 10}}], {{thePink, True, 
Style["Pink", Black, Bold, 12]}, {True, False}}, {{theGreen, True, 
Style["Green", Black, Bold, 12]}, {True, False}}]


b $ b

>

我想尝试调整的实际操作对象可以在这里找到:
目的是用一个不错的TogglerBar替换CheckBox。

The actual Manipulate object I am trying to adjust can be found there : http://www.laeh500.com/LAEH/COG.htmlThe purpose being to replace the CheckBox by a nice TogglerBar.

推荐答案

这样吗?

Manipulate[
 Graphics[{
   {White, Circle[{5, 5}, r]},  (* For Mma 7 compatibility*) 
   If[MemberQ[color, "Red"],   {Pink, Disk[{5, 5}, r]}],
   If[MemberQ[color, "Green"], {Green, Disk[{4, 2}, r]}]},
 PlotRange -> {{0, 20}, {0, 10}}],
 {{r, 1, "Radius"}, 1, 5, 1, ControlType -> Setter},
 {{color, "Red", "Color"}, {"Red", "Green"}, ControlType -> TogglerBar}, 
LabelStyle -> Large]

编辑

您的评论,我认为您的笔记本可以受益于这样的模板:

Answering your comment, I think your notebook could benefit from a template like this one:

Manipulate[
 Graphics[
  {
   {White, Circle[{5, 5}, r]},(* For Mma 7 compatibility*) 
   If[MemberQ[whatToDisplay, "Circle"], {Red,   Circle   [{5, 5}, r]}],
   If[MemberQ[whatToDisplay, "Square"], {Blue,  Rectangle[{5, 5}, {r, r}]}],
   If[MemberQ[whatToDisplay, "Other"],  {Black, Line     [Tuples[{3, 4}, 2]]}],
  },
 PlotRange -> {{0, 20}, {0, 10}}
 ], 
  (* Controls follow *)
  {{r, 1,  Style["Radius", Black, Bold, 12]}, 1, 5, 1, ControlType     -> Slider
                                                     , ControlPlacement-> Top
  },  
  Control@{{whatToDisplay, True, Style["What", Black, Bold, 12]}, 
           {"Circle", "Square", "Other"}, 
           ControlType      -> TogglerBar,
           Appearance       -> "Vertical",
           ControlPlacement -> Left
  }
]

这篇关于可以在数学中使用TogglerBar作为多个复选框吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 14:47